How to use the expo-app-auth.OAuthRedirect function in expo-app-auth

To help you get started, we’ve selected a few expo-app-auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo / packages / expo-google-app-auth / build / Google.js View on Github external
if (config.behavior !== undefined) {
        console.warn("Deprecated: Native Google Sign-In has been moved to Expo.GoogleSignIn ('expo-google-sign-in') Falling back to `web` behavior. `behavior` deprecated in SDK 34");
    }
    if (config.webClientId !== undefined) {
        console.warn('Deprecated: You will need to use expo-google-sign-in to do server side authentication outside of the Expo client');
    }
    const userDefinedScopes = config.scopes || [];
    /* Add the required scopes for returning profile data. */
    const requiredScopes = [...userDefinedScopes, 'profile', 'email', 'openid'];
    /* Remove duplicates */
    const scopes = [...new Set(requiredScopes)];
    const guid = getPlatformGUID(config);
    const clientId = `${guid}.apps.googleusercontent.com`;
    let redirectUrl = config.redirectUrl
        ? config.redirectUrl
        : `${AppAuth.OAuthRedirect}:/oauth2redirect/google`;
    try {
        const logInResult = await AppAuth.authAsync({
            issuer: 'https://accounts.google.com',
            scopes,
            redirectUrl,
            clientId,
        });
        // Web login only returns an accessToken so use it to fetch the same info as the native login
        // does.
        const userInfoResponse = await fetch('https://www.googleapis.com/userinfo/v2/me', {
            headers: { Authorization: `Bearer ${logInResult.accessToken}` },
        });
        const userInfo = await userInfoResponse.json();
        return {
            type: 'success',
            accessToken: logInResult.accessToken,
github expo / expo / packages / expo-google-app-auth / src / Google.ts View on Github external
'Deprecated: You will need to use expo-google-sign-in to do server side authentication outside of the Expo client'
    );
  }

  const userDefinedScopes = config.scopes || [];
  /* Add the required scopes for returning profile data. */
  const requiredScopes = [...userDefinedScopes, 'profile', 'email', 'openid'];
  /* Remove duplicates */
  const scopes = [...new Set(requiredScopes)];

  const guid = getPlatformGUID(config);

  const clientId = `${guid}.apps.googleusercontent.com`;
  let redirectUrl = config.redirectUrl
    ? config.redirectUrl
    : `${AppAuth.OAuthRedirect}:/oauth2redirect/google`;
  try {
    const logInResult = await AppAuth.authAsync({
      issuer: 'https://accounts.google.com',
      scopes,
      redirectUrl,
      clientId,
    });

    // Web login only returns an accessToken so use it to fetch the same info as the native login
    // does.
    const userInfoResponse = await fetch('https://www.googleapis.com/userinfo/v2/me', {
      headers: { Authorization: `Bearer ${logInResult.accessToken}` },
    });
    const userInfo = await userInfoResponse.json();

    return {

expo-app-auth

Deprecated Expo module for interfacing with the OpenID library AppAuth

MIT
Latest version published 2 years ago

Package Health Score

36 / 100
Full package analysis