Single Sign-on for React Native
Implement SSO for the OpenWeb React Native SDK
There are two types of SSO available: Standard and third-party single sign-on. Please contact your OpenWeb PSM if you are unsure which implementation method applies to you.
Implementation Options
Standard
- Authenticate a user with your backend user management system.
const onStartLoginFlow = (event) => {
...
}
const subscription = SpotIMEventEmitter.addListener('startLoginFlow', onStartLoginFlow);
- Call
startSSO
function and getcodeA
.
SpotIMAPI.startSSO()
.then(response => {
console.log(response);
})
.catch(error => {
console.error(error);
})
- Make a
GET /sso/v1/register-user
call to OpenWeb. The API call must include your secret access token (access_token
), the session ID generated after initiating the SSO session (codeA
), and required user details from your backend user management system (primary_key
,user_name
). Each of these parameters is defined in Add user information.
- Call
completeSSO
with thecodeB
.
SpotIMAPI.completeSSO("<CODE_B>")
.then(response => {
console.log(response);
})
.catch(error => {
console.error(error);
})
- Check
success
anderror
properties in the callback to ensure everything is okay.
Third-party single sign-on
- Authenticate a user with your third-party user management vendor.
- Call the
sso(JWTSecret)
function with a user JWT secret.
If there’s no error in the callback and response?.success
is true
, the authentication process finished successfully.
SpotIMAPI.sso("<SECRET_JWT>")
.then(response => {
console.log(response);
})
.catch(error => {
console.error(error);
})
Updated 4 months ago