Authentication

AccessToken is a resource that authorizes access to specific client data, such as their credit card information. To consume the methods of the Protected Card API, it is necessary to obtain the access_token in the OAuth 2.0 standard:

EnvironmentURL + EndpointAuthorization
SANDBOXhttps://authsandbox.braspag.com.br/oauth2/token"Basic {base64}"
PRODUCTIONhttps://auth.braspag.com.br/oauth2/token"Basic {base64}"
  1. Concatenate ClientId and ClientSecret (ClientId:ClientSecret).
  2. Encode the concatenation result in base64, creating a string.
  3. Send a request to the authorization server using the alphanumeric code created (string) - see example below.

ℹ️

Request the support team to create the ClientId and ClientSecret for your store to use in both SANDBOX and PRODUCTION environments.

Request

POST oauth2/token
--request POST "https://authsandbox.braspag.com.br/oauth2/token"
--header "Authorization: Basic _(Authorization)_"
--header "Content-Type: application/x-www-form-urlencoded"
--body "grant_type=client_credentials"
ParametersDescription
AuthorizationBasic (Authorization)
Content-Typeapplication/x-www-form-urlencoded
grant_typeclient_credentials

Response

{
  "access_token": "faSYkjfiod8ddJxFTU3vti_ ... _xD0i0jqcw",
  "token_type": "bearer",
  "expires_in": 599
}
ResponseDescription
access_tokenThe requested access token. The application can use this token to authenticate with the protected resource.
token_typeIndicates the value of the token type.
expires_inAccess token expiration, in seconds
After the token expires, you need to generate a new token.