You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

expo-auth-session

Package Overview
Dependencies
Maintainers
27
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-auth-session

Expo module for browser-based authentication

6.2.1
latest
Source
npmnpm
Version published
Weekly downloads
328K
2.54%
Maintainers
27
Weekly downloads
 
Created

What is expo-auth-session?

The expo-auth-session package is a library for handling authentication flows in Expo and React Native applications. It provides tools to manage OAuth 2.0 and OpenID Connect authentication, making it easier to integrate with various identity providers.

What are expo-auth-session's main functionalities?

OAuth 2.0 Authentication

This feature allows you to initiate an OAuth 2.0 authentication flow. The code sample demonstrates how to start an authentication session using a specified authorization URL and handle the result.

import * as AuthSession from 'expo-auth-session';

const authUrl = 'https://example.com/auth';
const redirectUrl = AuthSession.makeRedirectUri();

async function authenticate() {
  const result = await AuthSession.startAsync({ authUrl, returnUrl: redirectUrl });
  if (result.type === 'success') {
    console.log('Authentication successful:', result.params);
  }
}

OpenID Connect Support

This feature supports OpenID Connect, which is an identity layer on top of OAuth 2.0. The code sample shows how to use the discovery document to configure an authentication request and handle the response.

import * as AuthSession from 'expo-auth-session';

const discovery = AuthSession.useAutoDiscovery('https://example.com');

async function authenticateWithOIDC() {
  const request = new AuthSession.AuthRequest({
    clientId: 'your-client-id',
    scopes: ['openid', 'profile'],
    redirectUri: AuthSession.makeRedirectUri(),
  });

  const result = await AuthSession.startAsync({ authUrl: request.makeAuthUrl(), returnUrl: request.redirectUri });
  if (result.type === 'success') {
    console.log('OIDC Authentication successful:', result.params);
  }
}

Token Exchange

This feature allows you to exchange an authorization code for an access token. The code sample demonstrates how to perform a token exchange using the authorization code obtained from a successful authentication.

import * as AuthSession from 'expo-auth-session';

async function exchangeToken(authCode) {
  const tokenResponse = await AuthSession.exchangeCodeAsync({
    clientId: 'your-client-id',
    code: authCode,
    redirectUri: AuthSession.makeRedirectUri(),
    extraParams: {
      client_secret: 'your-client-secret',
    },
  });
  console.log('Access Token:', tokenResponse.accessToken);
}

Other packages similar to expo-auth-session

Keywords

react-native

FAQs

Package last updated on 03 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts