I am trying to implement google federated sign in, with AWS Amplify, in react native manged flow by expo, and a get a weird error only in my apple physical device.
I followed the documentation in <https://docs.amplify.aws/lib/auth/social/q/platform/js/#full-samples> and got this code:
import React, { useEffect, useState } from 'react';
import { Button, Linking, Platform, Text, View } from 'react-native';
import * as WebBrowser from 'expo-web-browser';
import Amplify, { Auth, Hub } from 'aws-amplify';
async function urlOpener(url, redirectUrl) {
const { type, url: newUrl } = await WebBrowser.openAuthSessionAsync(
url,
redirectUrl,
);
if (type === 'success' && Platform.OS === 'ios') {
WebBrowser.dismissBrowser();
return Linking.openURL(newUrl);
}
}
const [
localRedirectSignIn,
productionRedirectSignIn,
] = awsconfig.oauth.redirectSignIn.split(",");
const [
localRedirectSignOut,
productionRedirectSignOut,
] = awsconfig.oauth.redirectSignOut.split(",");
Amplify.configure({
. "aws_project_region": "us-east-1",
"aws_cognito_identity_pool_id": "us-east-1:27777e6d-857e-4187-84b6-85a17891d320",
"aws_cognito_region": "us-east-1",
"aws_user_pools_id": "us-east-1_MLaD0VGx7",
"aws_user_pools_web_client_id": "6kanfftqjuu7pgv7415or1hkl9",
"oauth": {
"domain": "velpaf3732cb1-f3732cb1-dev.auth.us-east-1.amazoncognito.com",
"scope": [
"aws.cognito.signin.user.admin",
"email",
"openid",
"phone",
"profile"
],
"redirectSignIn": "exp://127.0.0.1:19000/--/,
"redirectSignOut": "exp://127.0.0.1:19000/--/,
"responseType": "token"
},
"federationTarget": "COGNITO_USER_AND_IDENTITY_POOLS",
"aws_appsync_graphqlEndpoint": "https://tlpmf7idfvextlpbc4qrrmwgfy.appsync-api.us-east-1.amazonaws.com/graphql",
"aws_appsync_region": "us-east-1",
"aws_appsync_authenticationType": "API_KEY",
"aws_appsync_apiKey": "da2-3tpwvu3nobf35bk4mmx3m3gfnq",
"aws_user_files_s3_bucket": "velpanewversion3d014069f75d4be1bc2875498e9be3dc193449-staging",
"aws_user_files_s3_bucket_region": "us-east-1"
});
function App() {
const [user, setUser] = useState(null);
useEffect(() => {
Hub.listen('auth', ({ payload: { event, data } }) => {
switch (event) {
case 'signIn':
getUser().then((userData) => setUser(userData));
break;
case 'signOut':
setUser(null);
break;
case 'signIn_failure':
case 'cognitoHostedUI_failure':
console.log('Sign in failure', data);
break;
}
});
getUser().then((userData) => setUser(userData));
}, []);
function getUser() {
return Auth.currentAuthenticatedUser()
.then((userData) => userData)
.catch(() => console.log('Not signed in'));
}
return (
<View>
<Text>User: {user ? JSON.stringify(user.attributes) : 'None'}</Text>
{user ? (
<Button title="Sign Out" onPress={() => Auth.signOut()} />
) : (
<Button title="Federated Sign In" onPress={() => Auth.federatedSignIn()} />
)}
</View>
);
}
export default App;
This is my awsExport:
const awsmobile = {
"aws_project_region": "us-east-1",
"aws_cognito_identity_pool_id": "us-east-1:27777e6d-857e-4187-84b6-85a17891d320",
"aws_cognito_region": "us-east-1",
"aws_user_pools_id": "us-east-1_MLaD0VGx7",
"aws_user_pools_web_client_id": "6kanfftqjuu7pgv7415or1hkl9",
"oauth": {
"domain": "velpaf3732cb1-f3732cb1-dev.auth.us-east-1.amazoncognito.com",
"scope": [
"aws.cognito.signin.user.admin",
"email",
"openid",
"phone",
"profile"
],
"redirectSignIn": "exp://127.0.0.1:19000/--/,exp://exp.host/@mateodelat/velpa/",
"redirectSignOut": "exp://127.0.0.1:19000/--/,exp://exp.host/@mateodelat/velpa/",
"responseType": "token"
},
"federationTarget": "COGNITO_USER_AND_IDENTITY_POOLS",
"aws_appsync_graphqlEndpoint": "https://tlpmf7idfvextlpbc4qrrmwgfy.appsync-api.us-east-1.amazonaws.com/graphql",
"aws_appsync_region": "us-east-1",
"aws_appsync_authenticationType": "API_KEY",
"aws_appsync_apiKey": "da2-3tpwvu3nobf35bk4mmx3m3gfnq",
"aws_user_files_s3_bucket": "velpanewversion3d014069f75d4be1bc2875498e9be3dc193449-staging",
"aws_user_files_s3_bucket_region": "us-east-1"
};
export default awsmobile;
When I do the sign in with google from my virtual emulator device I can do a successful login.
Logging from my physical apple device, I can open the web browser but once authorized from google, get the following screen: Image error