Session Management

Login Using OAuth

Learn how to authenticate users using OAuth with the Okto SDK.

The loginUsingOAuth() method authenticates users using OAuth providers. It generates a session key pair, creates an authenticate payload, and sends it to the Gateway service. Upon successful authentication, it updates the user session.

Method Overview

MethodDescription
async OktoClient.loginUsingOAuthAuthenticate user using OAuth

Login Using OAuth

async OktoClient.loginUsingOAuth(data: AuthData) authenticates users using OAuth providers and establishes their session.

Parameters

ParameterTypeDescription
dataAuthDataAuthentication data containing the OAuth provider details

Where AuthData is one of:

TypeFieldsDescription
Google OAuth{ idToken: string; provider: 'google' }For authentication using Google OAuth
Okto Auth{ authToken: string; provider: 'okto' }For authentication using Okto token

Response

Success Response

Field NameTypeDescription
resultPromise<User>Returns the user data on successful login

Note

In case of errors, debug the error using the error code and refer to the SDK errors and warnings documentation for more details.

On this page