Authentication Forwarding

The StreamLayer SDK providers rich set of the features. Some of them requires user authentication - WatchParty, Chat, Whos'Watching, Gamification, Bettings and etc. The SDK provides several ways how to authenticate user so you can decide which one is better for you particular app. Let's overview all of them.


Bypass Authentication

If your host app has already been authenticated with the token verification system, you can forward that authentication token to the StreamLayer SDK. By doing so, your users won't need to authenticate repeatedly in our SDK - they will be automatically authenticated instead.

await StreamLayer.authorizationBypass("schema", "token")

Streamlayer SDK requests user data from the backend side. If response is successful client creates user entry into a database for SDK base on the received data.


Anonymous Authentication

In case when host app doesn't have authentication and you don't want to use phone authentication, you can use anonymous authentication. In this case the SDK will assign userID without collecting the phone number.


  await StreamLayer.useAnonymousAuth()

Managing Auth state

In case when you want remove current user from the SDK and clean user cache

 await StreamLayer.logout()

In case when you need to know current user auth state

// get current auth state - is user authorized or not
 await StreamLayer.isUserAuthorized()

// subscribe to auth state updates
 await StreamLayer.userIsAuthorizedState()