Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
'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 {