Privy offers the ability to sign up and log users in using OAuth providers. Users can sign in with familiar flows on Google, Apple, Twitter, Github, Discord, LinkedIn, TikTok, Spotify, Instagram, and LINE.
Login with OAuth is the onboarding flow your users are used to, integrated into your application in just a few lines of code.
The SDK supports OAuth login with . For all other OAuth providers, you can use JWT-based authentication.
Use initOAuth
from the useLoginWithOAuth
hook to trigger the OAuth login flow.
The OAuth provider to use for authentication. Valid values are: 'google'
, 'apple'
, 'twitter'
,
'github'
, 'discord'
, 'linkedin'
, 'spotify'
, 'tiktok'
, 'instagram'
, 'line'
.
If set to true, the OAuth flow will only allow users to log in with existing accounts and prevent new account creation.
Track the state of the OAuth flow via the state
variable returned by the useLoginWithOAuth
hook.
The current state of the OAuth flow.
The error that occurred during the OAuth flow (only present when status is ‘error’).
You can optionally pass callbacks to the useLoginWithOAuth
hook to run custom logic after a successful login or to handle errors.
onSuccess
The user object returned after successful login.
Whether the user is a new user or an existing user.
Whether the user was already authenticated before the OAuth flow.
The login method used (‘google’, ‘apple’, etc.).
The linked account if the user was already authenticated.
onError
The error that occurred during the OAuth flow.
We recommend configuring allowed OAuth redirect URLs to restrict where users can be redirected after they log in with an external OAuth provider. Learn more here!
The SDK supports OAuth login with . For all other OAuth providers, you can use JWT-based authentication.
Use initOAuth
from the useLoginWithOAuth
hook to trigger the OAuth login flow.
The OAuth provider to use for authentication. Valid values are: 'google'
, 'apple'
, 'twitter'
,
'github'
, 'discord'
, 'linkedin'
, 'spotify'
, 'tiktok'
, 'instagram'
, 'line'
.
If set to true, the OAuth flow will only allow users to log in with existing accounts and prevent new account creation.
Track the state of the OAuth flow via the state
variable returned by the useLoginWithOAuth
hook.
The current state of the OAuth flow.
The error that occurred during the OAuth flow (only present when status is ‘error’).
You can optionally pass callbacks to the useLoginWithOAuth
hook to run custom logic after a successful login or to handle errors.
onSuccess
The user object returned after successful login.
Whether the user is a new user or an existing user.
Whether the user was already authenticated before the OAuth flow.
The login method used (‘google’, ‘apple’, etc.).
The linked account if the user was already authenticated.
onError
The error that occurred during the OAuth flow.
We recommend configuring allowed OAuth redirect URLs to restrict where users can be redirected after they log in with an external OAuth provider. Learn more here!
The SDK supports OAuth login with . For all other OAuth providers, you can use JWT-based authentication.
Prior to integrating OAuth login, make sure you have properly configured your app’s allowed URL schemes in the Privy dashboard.
Privy supports native Apple login when running on iOS. To configure native Apple login, follow this guide.
Use login
from the useLoginWithOAuth
hook to authenticate users using an OAuth provider.
The OAuth provider to use for authentication. Valid values are: 'google'
, 'apple'
, 'twitter'
,
'github'
, 'discord'
, 'linkedin'
, 'spotify'
, 'tiktok'
, 'instagram'
.
If true, the OAuth flow will only allow existing users to log in, preventing new account creation.
The user object returned after successful login.
The promise returned by the login
method will reject with an error if the OAuth flow fails.
Track the state of the OAuth flow via the state
variable returned by the useLoginWithOAuth
hook.
The current state of the OAuth flow.
The error that occurred during the OAuth flow (only present when status is ‘error’).
The SDK supports OAuth login with . For all other OAuth providers, you can use JWT-based authentication.
Prior to integrating OAuth login, make sure you have properly configured your app’s allowed URL schemes in the Privy dashboard.
Privy supports native Apple login when running on iOS. To configure native Apple login, follow this guide.
To launch the oAuth flow, simply call privy.oAuth.login
. As parameters to this method, pass the following fields:
A member of the OAuthProvider
enum specifying which OAuth provider the user should login with. Currently, .google
, .apple
, .discord
, and .twitter
are supported.
(Optional). Your app’s URL scheme as a string. If you do not pass this value, Privy will use the first valid app URL scheme from your app’s info.plist
.
The authenticated Privy user
An error if logging the user in is unsuccessful.
That’s it! If your user was successfully authenticated, the login
method will return the new AuthSession.
An error could be thrown if:
If an error is thrown, you can get a description of the error as a string
from the error
thrown by privy.oAuth.login
.
To configure native apple login, follow this guide.
The SDK supports OAuth login with . For all other OAuth providers, you can use JWT-based authentication.
Prior to integrating OAuth login, make sure you have properly configured your app’s allowed URL schemes in the Privy dashboard.
Add the following activity to your AndroidManifest.xml
file to handle OAuth redirects:
Replace YOUR_CUSTOM_PRIVY_OAUTH_SCHEME
with your app’s custom URL scheme.
This scheme must be unique for this activity as it can cause issues if they clash with other activities or apps.
To launch the oAuth flow, simply call privy.oAuth.login
. As parameters to this method, pass the following fields:
A member of the OAuthProvider
enum specifying which OAuth provider the user should login with. Currently, Google
, Discord
, and Twitter
are supported.
Your app’s URL scheme as a string. This must match the scheme configured in your AndroidManifest.xml.
A Result
containing the authenticated PrivyUser
. Returns Result.success
with the PrivyUser if authentication was successful, or Result.failure
if there was an error.
That’s it! If your user was successfully authenticated, the login
method will return the authenticated PrivyUser
.
The login
method returns a Result
that will contain a failure if:
You can handle these errors using the onFailure
method as shown in the usage example above.
Prior to integrating OAuth login, make sure you have properly configured your app’s allowed URL schemes in the Privy dashboard.
To authenticate a user via an OAuth account (e.g. Google, Discord, Apple), use the Privy client’s OAuth
handler.
This is a two step process, though Privy’s Unity SDK wraps it into a single method call:
Privy’s Unity SDK currently supports OAuth login with Google, Apple, Twitter, and Discord.
We’re actively working to expand our support for other OAuth providers. Interested in a specific provider that isn’t currently supported? Contact us at [email protected].
To launch the OAuth flow, simply call PrivyManager.Instance.OAuth.LoginWithProvider
. As parameters to this method, pass the following fields:
A member of the OAuthProvider
enum specifying which OAuth provider the user should login with.
For WebGL builds, this will be your redirect URL. For applications, this will be your app’s URL scheme.
That’s it! If your user was successfully authenticated, the LoginWithProvider
method will return the new AuthState
for a user.
This method will throw an error if:
redirectUri
is not providedPrivy offers the ability to sign up and log users in using OAuth providers. Users can sign in with familiar flows on Google, Apple, Twitter, Github, Discord, LinkedIn, TikTok, Spotify, Instagram, and LINE.
Login with OAuth is the onboarding flow your users are used to, integrated into your application in just a few lines of code.
The SDK supports OAuth login with . For all other OAuth providers, you can use JWT-based authentication.
Use initOAuth
from the useLoginWithOAuth
hook to trigger the OAuth login flow.
The OAuth provider to use for authentication. Valid values are: 'google'
, 'apple'
, 'twitter'
,
'github'
, 'discord'
, 'linkedin'
, 'spotify'
, 'tiktok'
, 'instagram'
, 'line'
.
If set to true, the OAuth flow will only allow users to log in with existing accounts and prevent new account creation.
Track the state of the OAuth flow via the state
variable returned by the useLoginWithOAuth
hook.
The current state of the OAuth flow.
The error that occurred during the OAuth flow (only present when status is ‘error’).
You can optionally pass callbacks to the useLoginWithOAuth
hook to run custom logic after a successful login or to handle errors.
onSuccess
The user object returned after successful login.
Whether the user is a new user or an existing user.
Whether the user was already authenticated before the OAuth flow.
The login method used (‘google’, ‘apple’, etc.).
The linked account if the user was already authenticated.
onError
The error that occurred during the OAuth flow.
We recommend configuring allowed OAuth redirect URLs to restrict where users can be redirected after they log in with an external OAuth provider. Learn more here!
The SDK supports OAuth login with . For all other OAuth providers, you can use JWT-based authentication.
Use initOAuth
from the useLoginWithOAuth
hook to trigger the OAuth login flow.
The OAuth provider to use for authentication. Valid values are: 'google'
, 'apple'
, 'twitter'
,
'github'
, 'discord'
, 'linkedin'
, 'spotify'
, 'tiktok'
, 'instagram'
, 'line'
.
If set to true, the OAuth flow will only allow users to log in with existing accounts and prevent new account creation.
Track the state of the OAuth flow via the state
variable returned by the useLoginWithOAuth
hook.
The current state of the OAuth flow.
The error that occurred during the OAuth flow (only present when status is ‘error’).
You can optionally pass callbacks to the useLoginWithOAuth
hook to run custom logic after a successful login or to handle errors.
onSuccess
The user object returned after successful login.
Whether the user is a new user or an existing user.
Whether the user was already authenticated before the OAuth flow.
The login method used (‘google’, ‘apple’, etc.).
The linked account if the user was already authenticated.
onError
The error that occurred during the OAuth flow.
We recommend configuring allowed OAuth redirect URLs to restrict where users can be redirected after they log in with an external OAuth provider. Learn more here!
The SDK supports OAuth login with . For all other OAuth providers, you can use JWT-based authentication.
Prior to integrating OAuth login, make sure you have properly configured your app’s allowed URL schemes in the Privy dashboard.
Privy supports native Apple login when running on iOS. To configure native Apple login, follow this guide.
Use login
from the useLoginWithOAuth
hook to authenticate users using an OAuth provider.
The OAuth provider to use for authentication. Valid values are: 'google'
, 'apple'
, 'twitter'
,
'github'
, 'discord'
, 'linkedin'
, 'spotify'
, 'tiktok'
, 'instagram'
.
If true, the OAuth flow will only allow existing users to log in, preventing new account creation.
The user object returned after successful login.
The promise returned by the login
method will reject with an error if the OAuth flow fails.
Track the state of the OAuth flow via the state
variable returned by the useLoginWithOAuth
hook.
The current state of the OAuth flow.
The error that occurred during the OAuth flow (only present when status is ‘error’).
The SDK supports OAuth login with . For all other OAuth providers, you can use JWT-based authentication.
Prior to integrating OAuth login, make sure you have properly configured your app’s allowed URL schemes in the Privy dashboard.
Privy supports native Apple login when running on iOS. To configure native Apple login, follow this guide.
To launch the oAuth flow, simply call privy.oAuth.login
. As parameters to this method, pass the following fields:
A member of the OAuthProvider
enum specifying which OAuth provider the user should login with. Currently, .google
, .apple
, .discord
, and .twitter
are supported.
(Optional). Your app’s URL scheme as a string. If you do not pass this value, Privy will use the first valid app URL scheme from your app’s info.plist
.
The authenticated Privy user
An error if logging the user in is unsuccessful.
That’s it! If your user was successfully authenticated, the login
method will return the new AuthSession.
An error could be thrown if:
If an error is thrown, you can get a description of the error as a string
from the error
thrown by privy.oAuth.login
.
To configure native apple login, follow this guide.
The SDK supports OAuth login with . For all other OAuth providers, you can use JWT-based authentication.
Prior to integrating OAuth login, make sure you have properly configured your app’s allowed URL schemes in the Privy dashboard.
Add the following activity to your AndroidManifest.xml
file to handle OAuth redirects:
Replace YOUR_CUSTOM_PRIVY_OAUTH_SCHEME
with your app’s custom URL scheme.
This scheme must be unique for this activity as it can cause issues if they clash with other activities or apps.
To launch the oAuth flow, simply call privy.oAuth.login
. As parameters to this method, pass the following fields:
A member of the OAuthProvider
enum specifying which OAuth provider the user should login with. Currently, Google
, Discord
, and Twitter
are supported.
Your app’s URL scheme as a string. This must match the scheme configured in your AndroidManifest.xml.
A Result
containing the authenticated PrivyUser
. Returns Result.success
with the PrivyUser if authentication was successful, or Result.failure
if there was an error.
That’s it! If your user was successfully authenticated, the login
method will return the authenticated PrivyUser
.
The login
method returns a Result
that will contain a failure if:
You can handle these errors using the onFailure
method as shown in the usage example above.
Prior to integrating OAuth login, make sure you have properly configured your app’s allowed URL schemes in the Privy dashboard.
To authenticate a user via an OAuth account (e.g. Google, Discord, Apple), use the Privy client’s OAuth
handler.
This is a two step process, though Privy’s Unity SDK wraps it into a single method call:
Privy’s Unity SDK currently supports OAuth login with Google, Apple, Twitter, and Discord.
We’re actively working to expand our support for other OAuth providers. Interested in a specific provider that isn’t currently supported? Contact us at [email protected].
To launch the OAuth flow, simply call PrivyManager.Instance.OAuth.LoginWithProvider
. As parameters to this method, pass the following fields:
A member of the OAuthProvider
enum specifying which OAuth provider the user should login with.
For WebGL builds, this will be your redirect URL. For applications, this will be your app’s URL scheme.
That’s it! If your user was successfully authenticated, the LoginWithProvider
method will return the new AuthState
for a user.
This method will throw an error if:
redirectUri
is not provided