Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 9 Examples of "expo-app-auth in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'expo-app-auth' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

}
    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,
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,
}

  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,
'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 {
async function signInAsync() {
  const authState = await AppAuth.authAsync(config);
  await cacheAuthAsync(authState);
  console.log('signInAsync', authState);
  return authState;
}
async function refreshAuthAsync({ refreshToken }: { refreshToken: string }) {
  const authState = await AppAuth.refreshAsync(config, refreshToken);
  console.log('refresh', authState);
  await cacheAuthAsync(authState);
  return authState;
}
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;
  }
}
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,
  });
}
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

Is your System Free of Underlying Vulnerabilities?
Find Out Now