Skip to content

Authenticating with Saba Learning API #4

@mastrup

Description

@mastrup

I am trying to authenticate to the Saba REST API to retrieve courses.

In order to get a authorization code I need to request

https://<hostname-api.sabacloud.com>/v1/oauth2/authorize client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>=&response_type=code

This would give me a response like this:

{
    "@type": "com.saba.rest.dto.SabaOAuth2Code",
    "value": "19632da8-37b6-4446-85ec-30ee42d010c9",
    "redirectURI": null,
    "expiration": 0,
    "scope": null,
    "client": {
        "@type": "com.saba.rest.dto.SabaOAuth2Client",
        "id": "PMSite"
    },
    "relatedAuthCode": null,
    "relatedRefreshToken": null,
    "relatedAccessToken": null,
    "type": "AUTHORIZATION_CODE",
    "state": null,
    "site": null,
    "microAppId": null
}

By using the valuein the response, I am able to request a token by calling

https://<hostname-api.sabacloud.com>/v1/oauth2/token?grant_type=authorization_code&client_id=<CLIENT_ID>&source=RESTAPI&state=8

In this request I need to include the following 3 headers when calling the token endpoint:

  • username = The Saba username to authenticate
  • password = The password for that username.
  • authorization_code = The authorization code received in the authorize request.

I am not sure if this is possible to do with Umbraco Authorized Services?

If the request is successful, it would give me the following response:

{
 "@type": "com.saba.dto.AccessTokenDTO",
 "state": "8",
 "refresh_token": "yBHUZSAO6uqtXe+EDtLv+gVH3U3+bqGEDrEWGlGUSpt6ObRf8ohn2h5X1LWmcaPc",
 "expires_in": 604800000,
 "access_token": "<<encryptedData>>",
 "token_type": "Bearer"
}

When the token expires, I am able to refresh it by requesting:

https://<hostname-api.sabacloud.com>/v1/oauth2/token?grant_type=refresh_token&client_id=<CLIENT_ID>

I need to include the following header parameters to have it refreshed:

  • refresh_token = refresh_token received in access_token call
  • client_secret = consumer secret

This would give me the following response:

{
 "@type": "com.saba.dto.AccessTokenDTO",
 "state": null,
 "refresh_token": null,
 "expires_in": 604800000,
 "access_token": "<<encryptedData>>",
 "token_type": "Bearer"
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions