How to use expo-app-auth - 9 common examples

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.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,
            idToken: logInResult.idToken,
            refreshToken: logInResult.refreshToken,
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
}

  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 {
github expo / expo / apps / native-component-list / src / screens / AppAuthScreen.tsx View on Github external
async function signInAsync() {
  const authState = await AppAuth.authAsync(config);
  await cacheAuthAsync(authState);
  console.log('signInAsync', authState);
  return authState;
}
github expo / expo / apps / native-component-list / src / screens / AppAuthScreen.tsx View on Github external
async function refreshAuthAsync({ refreshToken }: { refreshToken: string }) {
  const authState = await AppAuth.refreshAsync(config, refreshToken);
  console.log('refresh', authState);
  await cacheAuthAsync(authState);
  return authState;
}
github expo / expo / apps / native-component-list / src / screens / AppAuthScreen.tsx View on Github external
async function signOutAsync({ accessToken }: { accessToken: string }) {
  try {
    await AppAuth.revokeAsync(config, {
      token: accessToken,
      isClientIdProvided: true,
    });
    await AsyncStorage.removeItem(StorageKey);
    return;
  } catch (error) {
    alert('Failed to revoke token: ' + error.message);
    return;
  }
}
github expo / expo / packages / expo-google-app-auth / src / Google.ts View on Github external
export async function logOutAsync({
  accessToken,
  ...inputConfig
}: GoogleLogInConfig & { accessToken: string }): Promise {
  const guid = getPlatformGUID(inputConfig);

  const clientId = `${guid}.apps.googleusercontent.com`;

  const config = {
    issuer: 'https://accounts.google.com',
    clientId,
  };

  return await AppAuth.revokeAsync(config, {
    token: accessToken,
    isClientIdProvided: !!clientId,
  });
}
github expo / expo / packages / expo-google-app-auth / build / Google.js View on Github external
export async function logOutAsync({ accessToken, ...inputConfig }) {
    const guid = getPlatformGUID(inputConfig);
    const clientId = `${guid}.apps.googleusercontent.com`;
    const config = {
        issuer: 'https://accounts.google.com',
        clientId,
    };
    return await AppAuth.revokeAsync(config, {
        token: accessToken,
        isClientIdProvided: !!clientId,
    });
}
//# sourceMappingURL=Google.js.map

expo-app-auth

Deprecated Expo module for interfacing with the OpenID library AppAuth

MIT
Latest version published 3 years ago

Package Health Score

36 / 100
Full package analysis

Similar packages