New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

expo-auth-session

Package Overview
Dependencies
Maintainers
0
Versions
109
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.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
107K
decreased by-2.38%
Maintainers
0
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

FAQs

Package last updated on 31 Jan 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc