Machine-to-machine authentication. No user involved — your app authenticates as itself.
Your Service OAuth Server
| |
|── POST /token ──────────►|
| client_id |
| client_secret |
| grant_type=client_cred |
|◄── access_token ─────────|
=== “Node.js”
```js
const SCGAuth = require('scg-auth');
const client = new SCGAuth({
clientId: 'my-service',
clientSecret: 'super-secret',
tokenUrl: 'https://your-server.com/token',
});
const tokens = await client.clientCredentials(['read:data', 'write:data']);
console.log(tokens.access_token);
console.log(tokens.expires_in); // seconds
```
=== “Python”
```python
from scg_auth import SCGAuth
client = SCGAuth(
client_id='my-service',
client_secret='super-secret',
token_url='https://your-server.com/token',
)
tokens = client.client_credentials(['read:data', 'write:data'])
print(tokens['access_token'])
print(tokens['expires_in'])
```