Version: current

Generating an Authorization Server

In this section you will understand how to generate the authorization token. Approximate reading time: 2 minutes

The OAuth2 protocol is the standard used by Juno for authorizations. Within the OAuth2 sessions, the Authorization Server is an important step of this layer, because it is through the Authorization Server that a Bearer Token type token will be generated with which the authentication will be performed and consequently the authorization for this particular integrator user to interact with our API.

For each endpoint call, the Bearer Token type token must be checked. Once you have the credentials (client_id and secret) in hand taken from the Juno platform, you can proceed with the request.

The generated Access Token expires with different deadlines in each environment, being necessary to renew it to authorize the requests

EnvironmentTime to Expiry
Sandbox86.400 seconds (24 hours)
Production3.600 seconds (1 hour)

The mandatory parameters that must be filled in are below:

HTTP MethodPOST
URLDepends on Environment
AuthorizationsBasicAuth
HeadersEmpty
BodyRequest Body Schema: x-www-form-unlerncoded Key Value grant-type "client_credentials"

Making the Call to our Authorisation Server

As said before, we'll use postman as an example to set up the requests - more information about it, you can find here.

For technical details, see our official documentation here.

What is Necessary to do this Request?

You must have already generated your credentials (Client_id, Secret and Private Token). If you have not yet generated your credentials, follow the steps in Generation an Authorization Token.

For technical details, see our official documentation here.

Just follow the steps below to make the API request:

  1. With a folder and a Request created, you can name it as you wish.

  2. For this request, set the http POST method;

  3. Next, insert the URL according to the endpoint and the environment.

  4. Go to Authorization;

  5. In Authorization, under Type, select the BasicAuth option;

  6. In Username, insert the client_id taken from the Juno platform

  7. In Password, insert the secret taken from the Juno platform.

  8. Go to Body;

  9. Fill in the Request Body Schema with x-wwww-form-unlerncoded;

  10. In Key, insert grant-type;

  11. In the column beside Value, insert client_credentials;

  12. Check if all the fields above are filled out correctly - after checking, you can go to Send

  13. See an example of Curl:

    ```bash curl --location --request POST 'https://sandbox.boletobancario.com/authorization-server/oauth/token' \ --header 'Authorization: Basic akU1ZEgxYkUyQTZhVGhEWjozOWlyU2NqV1psYkdCd1hCUF9rK0VtRmY3fFtTTXcleA==' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=client_credentials' ```

    A successful request will return a JSON response as output, like the one below:

    {
    {
    "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJlbWFudWVsZ3JhY2lhbm9ndWlyYXVkQGdtYWlsLmNvbSIsInNjb3BlIjpbImFsbCJdLCJleHAiOjE2MjgxODEwMTIsImp0aSI6Ik13RzhiM0VRclM3NkpaenBxNHhJTTJGM0F1byIsImNsaWVudF9pZCI6ImpFNWRIMWJFMkE2YVRoRFoifQ.EhLz-KjxN4Ttl05mSKd9KFydLF7_3iqOJlm6jiQ5gkLrPQhDieG5zrOarRBMh7Xvozu_UPHiNdAaZodFK6w0GOa9mg4gSzEC7f1x7DAHISlt6OmkHSps1oFzkg1hrsATV0xZ-grkHMppovcw5p2r96hP1hvAClwSFgr1aVWjuAapRVARHgdd0zEjAfJZFiYB_I1vB9sPuqMzMOENMH-9hVxXwFfFQdcuaSyKyTJ8KZzu8nvLCAUiGIw9z_LPnSkLqjHGIjLOQi0MXedl9loJDe1eoIiGOZGS1rJ9YXYwiFI0qwFxolLpW4mY5O4uH_6xNvVRTDfZepwGBEnf2FEzFw",
    "token_type": "bearer",
    "expires_in": 86399,
    "scope": "all",
    "user_name": "meuteste@teste.com",
    "jti": "MwA8b3EQrS76PZzpq4xIO2F3Auo"
    }
    }

If everything worked correctly, now you have the access_token in hand.

caution

CAUTION: A new OAuthToken should only be generated when it is close to expiring and/or has already expired. Massive requests to this endpoint may be blocked, jeopardising the integration.

With this, we can now start consuming the endpoints and go to the next step: Additional Data.

Last updated on by “ElderBalsani