Social Federation Not Working
See original GitHub issueDescribe the bug I am unable to get the signIn method of the hub listener to fire upon signin via Auth.federatedSignin().
Expected behavior When a user signs in via Google or Facebook (i.e. Auth.federatedSignin({provider: ‘facebook/google’})) they should be redirected back to my app (e.g. customdomain.com) and the signIn method of the hub listener should fire.
**Screenshots ** Here is a log that shows what happens when I log in Auth.federatedSignin({provider: ‘google’}):
As you can see, there are only two instances when an auth event is being dispatched, and it is only during initialization (on event parsingCallbackUrl). A subsequent auth event ‘signIn’ should be fired, but it is not.
What is Configured? I have oauth configured using @dabit3 's wonderful tutorial on social federation with amplify. I am using Cognito User Pools for authentication which allows social federation via Amazon, Google, and Facebook. I have a custom domain set up with route 53 and it has a hosted zone.
My exports file looks like the following:
const awsmobile = {
"aws_project_region": "us-west-2",
"aws_cognito_identity_pool_id": "us-west-2:xxx,
"aws_cognito_region": "us-west-2",
"aws_user_pools_id": "us-west-2_2MMItODxV",
"aws_user_pools_web_client_id": "xxx",
"oauth": {
"domain": "xxx-master.auth.us-west-2.amazoncognito.com",
"scope": [
"phone",
"email",
"openid",
"profile",
"aws.cognito.signin.user.admin"
],
"redirectSignIn": "https://mydomain.net/",
"redirectSignOut": "https://mydomain.net/",
"responseType": "code"
},
"federationTarget": "COGNITO_USER_POOLS",
"aws_appsync_graphqlEndpoint": "https://xxx.appsync-api.us-west-2.amazonaws.com/graphql",
"aws_appsync_region": "us-west-2",
"aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS",
"aws_user_files_s3_bucket": "xxx-master",
"aws_user_files_s3_bucket_region": "us-west-2"
};
Additional context
When I was following the aforementioned tutorial it worked like a charm in my dev environment. However, now that I have changed the redirect urls (via the amplify cli and on the google/facebook oauth accounts) the feature does not work. In face when I sign in, the google oauth redirects to mydomain.com/#
, as opposed to the expected redirect: mydomain.com/
. Facebook also redirects in a strange way by forwarding to mydomain.com/#_=_
, as opposed to mydomain.com/
. I’m not sure if this is significant or not. As far as I can tell, the oauth providers have been set up properly (on the facebook/google dev sites). I have pasted the oauth endpoints (e.g. xxx-master.auth.com) in the correct places and I am really frustrated that I can’t get this thing to work 😕
I should also mention that this feature was working before I tried setting up my custom domain.
edit: After doing some testing I found that this feature works on my dev environment which is hosted with the amplify console. With this setup my auth resources and storage (hosting) resources match up nicely (e.g. xxx-amplifydev.auth.com & xxx-amplifydev.com). However, on my master environment the resources do not match up (e.g. mydomain.com & xxx-amplifymaster.auth.com). I have a feeling that the error lies in this discrepancy. Is there anything special I have to setup when using a custom domain and social federation?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
I am experiencing the same behavior, and had to implement the hack in this issue.
same error