How to handle authentication and OAuth in Xano

Maxime Topolov
Maxime Topolov
June 10, 2024
How to handle authentication and OAuth in Xano

Xano provides several options for integrating authentication and OAuth providers into your application. This article will cover best practices and technical details for integrating Google OAuth, Azure AD SSO, and Facebook OAuth with Xano.

Google OAuth Integration

To integrate Google OAuth with Xano:

1. Set up your Google OAuth credentials in the Google Cloud Console, specifying the appropriate redirect URIs. For mobile apps, no redirect URIs or client secrets are needed. (

2. Install the Google OAuth extension in your Xano workspace. Complete all setup steps provided in the extension instructions.

3. When making the authorization request to Google, use the web client ID for all platforms, including mobile. (

4. After obtaining the authorization code from Google, the /oauth/google/continue endpoint in Xano may fail to create the magic link due to the code being encoded. Apply a filter to decode the code parameter before using it. (

5. Ensure the magic_link_redirect_uri and magic_jwt_secret environment variables are set correctly in your Xano workspace settings for the magic link to be generated successfully. (

Azure AD SSO Integration

To integrate Azure AD SSO with Xano APIs:

1. Use the Microsoft Graph API login process to obtain an ID Token from Azure AD.

2. Create an endpoint in Xano that validates the ID Token and exchanges it for a Xano access token. This allows you to leverage Xano's built-in authentication without weaknesses in the authentication chain. (

3. To validate the ID Token in Xano:
  a. Decode the token using the jwt_decode function, which verifies the signature using the provided secret key.
  b. Check the token claims, such as issuer, audience, expiration time, not before time, and issued at time.
  c. If the token is valid, associate the user in the token with a user in your application based on the subject claim. (

Facebook OAuth Integration

To set up Facebook OAuth with Xano:

1. Configure your Facebook OAuth credentials in the Facebook Developer Console.

2. Install the Facebook OAuth Marketplace extension in your Xano workspace.

3. When using the /oauth/facebook/init endpoint with a front-end like WeWeb, ensure the endpoint navigates to the generated auth_url. If the navigation doesn't happen automatically, you may need to manually trigger the navigation in your front-end code. (

General OAuth Considerations

To connect multiple social accounts to a user, install separate instances of the OAuth extension for each provider, configuring different client IDs and secrets for each instance. (

- When storing access tokens, consider token expiration and implement token refresh mechanisms as needed. Limit access token lifetimes to mitigate risks associated with compromised tokens. (

How OAuth Works

OAuth (Open Authorization) is an open standard for access delegation, commonly used as a way for Internet users to grant websites or applications access to their information on other websites without giving them the passwords. The OAuth process typically involves the following steps:

1. Application Registration: The application that wants to access the user's resources registers with the OAuth provider (e.g., Google, Facebook, Azure AD). The provider issues client credentials, such as a client ID and client secret, to the application.

2. Authorization Request: When a user wants to grant the application access to their resources, the application directs the user to the OAuth provider's authorization server. The authorization request includes the client ID, requested scope (permissions), and a redirect URI.

3. User Authentication and Consent: The user authenticates with the OAuth provider and is presented with a consent screen outlining the permissions the application is requesting. If the user grants consent, the OAuth provider redirects the user back to the application's redirect URI with an authorization code.

4. Token Exchange: The application sends a request to the OAuth provider's token endpoint, including the authorization code, client ID, client secret, and redirect URI. If the code is valid, the provider returns an access token (and optionally, a refresh token) to the application.

5. Resource Access: The application uses the access token to make requests to the OAuth provider's API on behalf of the user. The API validates the access token and, if valid, returns the requested resources.

6. Token Refresh: If a refresh token was issued, the application can use it to obtain a new access token when the current one expires, without requiring the user to re-authenticate.

Are SSO and OAuth the same?

No! SSO (Single Sign-On) and OAuth (Open Authorization) are related but distinct concepts.

SSO is a mechanism that allows users to authenticate once and gain access to multiple applications without needing to log in separately for each one.

OAuth, on the other hand, is an authorization framework that enables users to grant third-party applications limited access to their resources without sharing their credentials.

What is the difference between oauth2 and oauth?

OAuth (OAuth 1.0) and OAuth 2.0 are open standards for authorization, differing in complexity, flexibility, and security. OAuth 1.0 is a strict, complex protocol requiring cryptographic signing of each request, focusing on high security through signed tokens (HMAC-SHA1 or RSA-SHA1). In contrast, OAuth 2.0 simplifies the process by using bearer tokens without needing request signing, relying on secure transport protocols like HTTPS. OAuth 2.0 introduces multiple grant types (e.g., Authorization Code, Implicit) to cater to different use cases and supports refresh tokens, improving user experience. While OAuth 1.0 is less adopted due to its complexity, OAuth 2.0's flexibility and ease of use have made it the standard for modern authorization, though its security depends heavily on proper HTTPS implementation.

What is the difference between openid and oauth2?

OpenID and OAuth2 serve different purposes in identity and access management. OpenID is primarily for authentication, enabling users to log into multiple sites with a single set of credentials, focusing on verifying user identity for single sign-on (SSO) systems. In contrast, OAuth2 is designed for authorization, allowing third-party applications to access a user's resources without exposing their credentials, by granting limited access through authorization tokens. OpenID uses ID tokens for identity verification, while OAuth2 uses access and refresh tokens for resource access. OpenID involves a straightforward authentication flow, whereas OAuth2 supports multiple flows for various scenarios. OpenID enhances user convenience across multiple sites, while OAuth2 provides secure, flexible resource access for third-party applications.

Share this post
Business Apps
Software Engineering
Maxime Topolov
Maxime Topolov

You can also read

Consumer App
Software Engineering
Mobile Dev
Content Migration
Business Apps
Conversional AI
Media and Publishing
Financial services
Large corporate