Citesphere uses OAuth2 for handling authentication and authorization. You can use any form of OAuth Client to get the token, which needs to be passed to other APIs as a header.
Using Citesphere to Authenticate Users for Single Sign-On
1. Authorizing Application
Prerequisites
You should have created an application in Citesphere. If not, create one! Make sure to choose “Apps need user information (Authorization Code)” as application type and to provide a url to which Citesphere should redirect after authorizing a user in “Redirect URL.”
You should have the following information for the application with you:
client_id
- A unique identifier for your application. This is auto-generated for you during the application creation.Example:
OAUTHCLIENT007
client_secret
- An auto-generated secret identifier which will be visible only right after you create the application. If you had lost it, go back and create a new applicationregenerate the secret.redirect_url
- You should have given a callback URL while creating the application in Citesphere. If you forgot this, you can check it back in Citesphere.
Authorization Flow
From your application, redirect your user to the following URL with specified parameters. Maybe have a button that says
Status | ||||
---|---|---|---|---|
|
...
Info |
---|
Note that this step happens in the browser, initiated by your application’s user. That means Your application should have a controller in the backend to retrieve |
2. Get Access Token
Note |
---|
This step should NOT be done in the browser. Why? You have to pass your At any cost, you should NOT expose your |
...
expires_in
specifies the number of seconds remaining for theaccess_token
to expire.You should use the
access_token
as the Bearer token header for accessing any resource.Header Name -
Authorization
Header Value -
Bearer 2c7c0f10-adf5-ed55-a931-caeea29464ee
You should use the
refresh_token
in order to get a newaccess_token
once it is expired
3. Refresh Token
You would need to call this API for getting a new access_token
if it expired. Your application should ideally store the refresh_token
generated previously (ex. database). Use the refresh_token
to retrieve a new access_token
.
...