SDKs & Sample Apps
SDKs

AAA SDK

17min

Authentication And Authorization (AAA) SDK for Web

The AAA SDK for Web is built on top of react, oidc-react, and typescript. This SDK can be used for authentication, maintaining access tokens, fetching user info, and appending headers to the REST API calls.

To learn more about AAA, see Authentication And Authorization.

Installation

Install @os1-platform/aaa-web into your project.

Text


Peer Dependencies

The AAA SDK has the following peer dependencies:

JS


Usage

Use the initCAS API of the SDK to create auth instance and fetch the AuthProvider component.

JS


Wrap your application in this single AuthProvider component. For example:

JS


OR

JS


Pass the loader component to the AuthProvider to override the default loader.

JS


Use the loginWithRedirect method to initiate login.

JS


Use the isAuthenticated method to put a check on private pages:This checks if the user has valid permissions to access private pages that require access via token, unlike public pages like the 'Contact Us' page.

JS


Use the getAccessTokenSilently method, to fetch the access token.

JS


Use the getUserInfo method, to fetch user info.

JS


Use the HttpClient API to create a client for network requests.

JS


The following headers are automatically configured to requests originating from the NetworkClient adding Access token(x-coreos-access) or the Tenant ID(x-coreos-tid) or User info(x-coreos-userinfo) or Auth token(x-coreos-auth) headers to the actual request.

  • withAccess
  • withTid
  • withUserInfo
  • withAuth

Note:

  • By default all these headers are true, i.e., will be passed to the REST API. The user needs to specifically pass value against these headers as false if they don't wish to pass certain headers.
  • Access token is verified and regenerated (if expired), every time an API request is made.
  • x-coreos-userinfo contains the userId.
  • x-coreos-auth contains the id_token.
JS

  1. Use the logout method, to implement logout functionality.
JS


Authentication And Authorization (AAA) SDK for Mobile

The AAA (Authentication And Authorization) SDK for mobile is used for authentication purposes to integrate with the front-end applications. This SDK is built on top of react-native, react-native-app-auth, and typescript. You can use this SDK on mobile for authentication, fetching access tokens, and logout features.

To learn more about AAA, see AAA Documentation.

Installation

Install @os1-platform/aaa-mobile into your project.

Text


Install Peer Dependencies

Text


Add Manifest Placeholder in build.gradle (app level)

Text


Usage

Init AAA SDKinitAuth0 initiates the authentication process and creates an instance of auth.

JS


Initiate LogininitLogin() uses the auth instance and opens the web page on mobile containing the OS1 login page.

JS


Logout

JS


Fetch Access Token

JS


Refresh Token

JS




Updated 28 Feb 2024
Did this page help you?