Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Social Login (Facebook) through user pool, hosted, ui, invalid_grant error. #3185

Closed
calboru opened this issue Apr 28, 2019 · 8 comments
Closed
Labels
Auth Related to Auth components/category documentation Related to documentation feature requests

Comments

@calboru
Copy link

calboru commented Apr 28, 2019

Followings are my settings. When I try to test social login I always get invalid_grant error.

WHEN I INVOKE:
federatedSignIn() {
const provider: FederatedSignInOptionsCustom = { customProvider: 'Facebook' };
return from(this.auth.federatedSignIn(provider));
}

OR TEST URL: https://xxxx.auth.us-east-2.amazoncognito.com/login?response_type=code&client_id=xxxx&redirect_uri=https://localhost:4200

Error happens after PKCE event: https://localhost:4200/?code=16c65151-7f92-4611-99c3-d872a44cacb6

MY SETTINGS AS FOLLOW:
const awsmobile = {
aws_project_region: 'us-east-2',
aws_cognito_region: 'us-east-2',
aws_user_pools_id: 'us-east-2_XXX',
aws_user_pools_web_client_id: 'XXXXX',
Auth: {
oauth: {
domain: 'XXX.auth.us-east-2.amazoncognito.com',
redirectSignIn: 'https://localhost:4200',
redirectSignOut: 'https://localhost:4200',
mandatorySignIn: true,
scope: ['public_profile', 'openid', 'email', 'first_name', 'last_name'],
responseType: 'code'
}
}
};
image

image

image

@calboru calboru changed the title Social Login through user pool, hosted, ui, invalid_grant error. Social Login (Facebook) through user pool, hosted, ui, invalid_grant error. Apr 28, 2019
@manueliglesias
Copy link
Contributor

Hi @calboru

invalid_grant could mean that:

  • Refresh token has been revoked.
  • Authorization code has been consumed already or does not exist.

(According to TOKEN Endpoint docs)

Do you see duplicate/multiple calls to the token endpoint in the network inspector?

@manueliglesias manueliglesias added the Auth Related to Auth components/category label Apr 30, 2019
@calboru
Copy link
Author

calboru commented May 1, 2019

Hi @calboru

invalid_grant could mean that:

  • Refresh token has been revoked.
  • Authorization code has been consumed already or does not exist.

(According to TOKEN Endpoint docs)

Do you see duplicate/multiple calls to the token endpoint in the network inspector?

Hi Manuel,
Yes I saw two calls even though I call it once. Is it an amplify bug?

@nandoise
Copy link

nandoise commented May 15, 2019

invalid_grant ; Zone ; Task Promise.then ; Value: Error: invalid_grant ... zone.js


It seems you are calling two times, in you code.

you set at begining the imports

import Amplify, { Auth } from 'aws-amplify';
import amplify from './aws-exports';

Amplify.configure(amplify); //something like this


this is all.. but in some tutorials give an extra step (not necesary)..

ej.

oauth = {
    domain: 'you-domain.auth.us-east-1.amazoncognito.com',
    scope: ['phone', 'email', 'profile', 'openid', 'aws.cognito.signin.user.admin'],
    redirectSignIn: 'http://localhost:4200',
     redirectSignOut: 'http://localhost:4200',
     responseType: 'code',
    options: {
      AdvancedSecurityDataCollectionFlag : false
    }
};

Auth.configure({ 
  oauth: oauth
 })

This is not necesary because your "import amplify from './aws-exports';" has the same parameters,

REVIEW
Check you development tool f12 if you has something like this [img], just comment the (extra step)

err

@jordanranz
Copy link
Contributor

@nandoise, I too ran into this issue. Removing the manual config from the documentation example fixed the 'invalid_grant' error.

@jordanranz jordanranz added the documentation Related to documentation feature requests label Jun 6, 2019
@stale
Copy link

stale bot commented Jul 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented Jul 13, 2019

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

@stale stale bot closed this as completed Jul 13, 2019
@MTajuddin96
Copy link

Write Amplify.configure(awsConfig) after your initial component mounted. This actually solved my issue.

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Auth Related to Auth components/category documentation Related to documentation feature requests
Projects
None yet
Development

No branches or pull requests

5 participants