Get an access token
POST
/oauth/token
const url = 'https://api.devsecure.io/oauth/token';const options = { method: 'POST', headers: { Authorization: 'Basic <credentials>', 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ grant_type: 'client_credentials', scope: 'issues:read scans:read', client_id: 'devsc_exampleexample00', client_secret: 'example' })};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.devsecure.io/oauth/token \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data grant_type=client_credentials \ --data 'scope=issues:read scans:read' \ --data client_id=devsc_exampleexample00 \ --data client_secret=exampleExchange OAuth client credentials for a short-lived bearer access token (client credentials grant). The token carries the client’s scopes, or the requested subset.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/x-www-form-urlencoded
object
grant_type
required
string
scope
Optional space-separated subset of the client’s scopes.
string
client_id
Only when not using HTTP Basic.
string
client_secret
Only when not using HTTP Basic.
string format: password
Responses
Section titled “Responses”OK.
Media typeapplication/json
TokenResponse
object
access_token
required
Access Token
string
token_type
Token Type
string
expires_in
required
Expires In
Seconds until the token expires.
integer
scope
required
Scope
Space-separated scopes.
string
Example
{ "access_token": "devsat_exampleexample00_EXAMPLE-not-a-real-token-EXAMPLE-0000000", "token_type": "Bearer", "expires_in": 3600, "scope": "issues:read scans:read"}Headers
Section titled “Headers”X-Request-ID
string
Identifies the request; quote it to support.
Invalid request, grant type or scope.
Media typeapplication/json
Client authentication failed.
Media typeapplication/json
The workspace’s plan does not include API access.
Media typeapplication/json
Too many requests.
Media typeapplication/json