Oauth

Adservio currently supports multiple authorization flow.

  • Implicit flow
  • Authorization Code Flow
  • Client Credentials Flow

The Authorization Code Flow is preffered.

Authorization Code Flow

The flow is initialized by redirect the user to https://www.adservio.ro/oauth2/authorize with the required query string parameters (see Authorize endpoint).

After the authentification is done and consent is given for the required permissions the user will be redirected to the redirect_uri with the following parameters added:

  • code = the authorization code used in token exchange (see Token endpoint)
  • state = the same value as the state parameter received

After the code is received the server should exchange the code for an access token using the Authorize endpoint.

Warning: The token exchange must be on done on server side. Never expose the client_secret.

Authorize Endpoint

Used to initialize an oauth flow. The can be a full page redirect or it can be opened in an appropriately sized modal.

Query string parameters

NameValue TypeValidationDetails
response_typestringRequiredvalues[code,token]; The flow used. Use code for Authorization Code Flow or token for implicit flow.
client_idstringRequiredThe client id provided by Adservio.
redirect_uristringRequiredThe callback URL that the user will be redirected to. Must be preapproved by Adservio.
statestringOptionalValue that will be returned as is.

Token Endpoint

Used to exchange the authorization code with an access token. This must be called from the backend side of the application using the POST method. Never expose client_secret to the user.

Output example

{
access_token: "eyAA.....",
expires_at: "2021-12-28 13:33:22"
}

POST parameters

NameValue TypeValidationDetails
grant_typestringRequiredvalues[authorization_code]; The flow used. Must be authorization_code.
codestringRequiredThe authorization code received in the Authorize Flow.
client_idstringRequiredThe client id provided by Adservio.
client_secretstringRequiredThe client secret provided by Adservio.