question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Server error when trying to login with Facebook federatedSignIn

See original GitHub issue

Description

I had successfully setup Facebook and Google sign in using federatedSignIn method in the Auth module. However, recently the flow breaks returning a server error.

My Config

aws_config: {
    Auth: {
      identityPoolId: 'ap-southeast-1:my id',
      region: 'ap-southeast-1',
      userPoolId: 'ap-southeast-my id',
      userPoolWebClientId: 'my client id',
      mandatorySignIn: false,
    },
  },
  oauth: {
    domain: 'my domain.auth.ap-southeast-1.amazoncognito.com',
    scope: ['phone', 'email', 'profile', 'openid', 'aws.cognito.signin.user.admin'],
    redirectSignIn: 'http://localhost:4200/',
    redirectSignOut: 'http://localhost:4200/',
    responseType: 'code'
  }

Steps to reproduce the behavior:

In my authenticator service (As I am using angular) the method is as follows

  loginFacebook() {
    Auth.federatedSignIn({customProvider: 'Facebook'}).then(() => {

    }).catch(e => {
      console.log(e);
    });
  }

Expected behaviour

The redirect after user authorization should come with access code followed by login success event in the following handler.

Hub.listen('auth', (data) => {
        switch (data.payload.event) {
          case 'signIn':
            console.log('Login success');
            Auth.currentAuthenticatedUser().then((u) => {
              this.processUser(u);
              resolve(true);
            }).catch((e) => {
            });
            break;
          case 'signOut':
            console.log('Logout success');
            this.isLoggedIn = false;
            this.user = null;
            this.autoLogin = false;
            resolve(false);
            break;
        }
      });

Current behaviour

The user gets redirected to https://www.vinyl.lk/?error_description=Exception%20processing%20authorization%20code&state=GiFNGdcwLTaut52DH6qsZWuSoMaQWPVH&error=server_error#_=_

Apparently, the code is retrieved. However, it is not processed by cognito for some reason. Google login works perfect and Facebook login tend to fail like this. (In rare cases the login happens as expected.)

The network calls relevant to the use case

image

Versions of SDK used

   ...
   "amazon-cognito-identity-js": "^3.0.12",
   "aws-amplify": "^1.1.29-unstable.0",
   "aws-sdk": "^2.466.0",
   ...

Note: I tried with stable version “1.1.29” still not luck (which used to work perfectly on either of version before sometime.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
cliffordhcommented, Jun 20, 2019

Same issue… tbh, I’m glad it’s not just me! Looking forward to a solution. I suspect it’s a timing issue, when I set a breakpoint in the oauth response handler and pause before continuing then it seems to work more reliably (have not heavily tested this).

1reaction
sophiadeakcommented, Jul 24, 2019

I had the same error but it turns out I had tried to map attributes that Google wasn’t returning.

I found this helpful https://stackoverflow.com/a/56979795/10929504

Read more comments on GitHub >

github_iconTop Results From Across the Web

Amplify Federated Sign In not returning Email for Facebook ...
I am trying to add Facebook and I have everything working except that the email is not inside my Cognito attributes for the...
Read more >
Recover Your Facebook Account if You Can't Log In.
If you're having trouble logging into your account, review these tips and known login issues.
Read more >
Authentication - Social sign-in (OAuth) - JavaScript
From the navigation bar choose Facebook Login and then Settings. Type your redirect URL into Valid OAuth Redirect URIs. It will consist of...
Read more >
The Complete React Native Guide to User Authentication with ...
Amazon Cognito User is a managed user directory service that handles user registration, ... i.e. Facebook login + Username / password login.
Read more >
Federated Sign-in - Accounts - Zoho Cares
You can sign in to your Zoho account without using a password. Learn about federated ... Click the service account you want to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found