What is Machine-to-Machine (M2M) Authentication?
Machine-to-machine (M2M) authentication is the process of allowing two applications or services to communicate securely without a user present. Instead of passwords or API keys, each service uses its own Client ID and Client Secret to request a short-lived access token. This ensures secure, auditable, and revocable service-to-service authentication, widely used in backend integrations, microservices, and IoT systems.
Read our docsBenefits of using M2M tokens
Common Use Cases
Application Backends
Securely transfer data, logs, or files between internal and external services.
CLI Tools
Let command-line tools securely access APIs using short-lived, scoped tokens.
Scheduled Jobs & Daemons
Authorize cronjobs, job schedulers, and background workers to interact with APIs safely and efficiently.
IoT Devices
Enable smart devices to send data to your cloud services automatically for telemetry or commands, with each device authenticated and scoped individually.
How it Works
Register Your Resources
Add APIs to Authgear and define the scopes (permissions) for each of them
Register Your Application
Create a client application for each backend, device, or tool that needs API access. Assign the resources and scopes available to the service
Obtain Credentials
Each application receives a unique client ID and secret
Request a Token
The application authenticates with Authgear using the /oauth/token endpoint, and receives a short-lived access token, containing only the scopes you've assigned.
Access Protected APIs
The service uses the bearer token in the Authorization header to call your APIs
Frequently Asked Questions (FAQ)
What is machine-to-machine (M2M) authentication?
M2M authentication is a method that allows services or applications to securely communicate without user credentials. Instead, services exchange M2M tokens (short-lived access tokens) via the OAuth Client Credentials Flow.
How does the OAuth Client Credentials Flow work?
The Client Credentials Flow issues an access token directly to a machine or service (not a user). A service authenticates using its Client ID and Secret and receives a JWT token it can use to access protected APIs.
Why use M2M tokens instead of API keys?
M2M tokens are short-lived, scoped, and revocable. Unlike static API keys, they improve security by limiting exposure and allowing fine-grained access control.
Can I use M2M authentication for microservices?
Yes. M2M authentication is commonly used for microservice-to-microservice communication, ensuring secure backend API calls without embedding static secrets.