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