Get a JWT token for REST API calls Skip Navigation

Get a JWT token for REST API calls

  1. Get a refresh token from the 
    BlackBerry
     myAccount online service. Use the same myAccount credentials that you use to log in to the 
    BlackBerry Analytics
     portal. Refresh tokens are valid for a long time. Access tokens expire in the interval indicated, in minutes.
    Request to the server:
    curl --request POST --data "client_id=com.good.oauth2.client.general&grant_type=password&username= user@domain&password=account_password" https://login.blackberry.com/sso/oauth2/access_token
    Response from the server:
    {"scope":"com.good.oauth2.client.general goodCurUserLevel goodOrgID goodOrgRole goodOrgType inetUserStatus mail o","expires_in":600,"token_type":"Bearer","refresh_token":" TOKEN_VALUE ","access_token":" TOKEN_VALUE "}
  2. You can use a refresh token to generate a new access token. Persist the refresh token in a secure storage location that is accessible to your app.
    Request to the server:
    curl --request POST --data "client_id=com.good.oauth2.client.general&grant_type=refresh_token& refresh_token=TOKEN_VALUE" https://login.blackberry.com/sso/oauth2/access_token
    Response from the server:
    {"scope":"com.good.oauth2.client.general goodCurUserLevel goodOrgID goodOrgRole goodOrgType inetUserStatus mail o","expires_in":600,"token_type":"Bearer","access_token":"TOKEN_VALUE"}
  3. Exchange the access token for a JWT token at the 
    BlackBerry Analytics
     portal.
    Request to the server:
    curl https://analytics.blackberry.com/enterpriseportal/api/v2/auth/oauth?accessToken=TOKEN_VALUE
    Response from the server:
    {"JWTToken":"JWT_TOKEN_VALUE"}
  4. Make 
    BlackBerry Analytics
     API calls with the JWT token. The JWT token expires after 1 hour. You can repeat steps 2 and 3 to get a new JWT token.
    Request to the server:
    curl -H 'Authorization:Bearer <JWT_TOKEN>' https://analytics.blackberry.com/enterpriseportal/api/v2/os
    Response from the server:
    [{"versions":[{"name":"4.1.2"},{"name":"4.4.2"},{"name":"4.4.3"},{"name":"4.4.4"},{"name":"5.0"},{"name":"5.0.1"},{"name":"5.0.2"},{"name":"5.1"},{"name":"5.1.1"},{"name":"6.0"},{"name":"6.0.1"},{"name":"7.0"},{"name":"7.1"},{"name":"7.1.1"},{"name":"7.1.2"},{"name":"8.0.0"},{"name":"O"}],"osName":"Android"},{"versions":[{"name":"8.1.0"},{"name":"9"},{"name":"p"}],"osName":"android"},{"versions":[{"name":"10.0"},{"name":"10.0.1"},{"name":"10.0.2"},{"name":"10.0.3"},{"name":"10.1"},{"name":"10.1.1"},{"name":"10.2"},{"name":"10.2.1"},{"name":"10.3"},{"name":"10.3.1"},{"name":"10.3.2"},{"name":"10.3.3"},{"name":"11.0"},{"name":"8.0.2"},{"name":"8.1.1"},{"name":"8.1.3"},{"name":"8.2"},{"name":"8.3"},{"name":"8.4"},{"name":"8.4.1"},{"name":"9.0"},{"name":"9.0.1"},{"name":"9.0.2"},{"name":"9.1"},{"name":"9.2"},{"name":"9.2.1"},{"name":"9.3"},{"name":"9.3.1"},{"name":"9.3.2"},{"name":"9.3.3"},{"name":"9.3.4"},{"name":"9.3.5"}],"osName":"iOS"},{"versions":[{"name":"11.0.1"},{"name":"11.0.2"},{"name":"11.0.3"},{"name":"11.1"},{"name":"11.1.1"},{"name":"11.1.2"},{"name":"11.2"},{"name":"11.2.1"},{"name":"11.2.2"},{"name":"11.2.5"},{"name":"11.2.6"},{"name":"11.3"},{"name":"11.3.1"},{"name":"11.4"},{"name":"11.4.1"},{"name":"12.0"}],"osName":"ios"}]