Auth-module: Request to https://<cognito domain>.auth.<cognito region>.amazoncognito.com/oauth2/token returns 400 response

Created on 29 May 2018  路  3Comments  路  Source: nuxt-community/auth-module

I'm trying to use AWS Cognito via the OAuth2 scheme and cannot for the life of me figure it out. My configuration...

strategies: {
    dev: {
        _scheme: 'oauth2',
        authorization_endpoint: 'https://<cognito domain>.auth.<cognito region>.amazoncognito.com/oauth2/authorize',
        userinfo_endpoint: 'https://<cognito domain>.auth.<cognito region>.amazoncognito.com/oauth2/token',
        scope: ['openid', 'profile', 'email', 'phone'],
        response_type: 'token',
        token_type: 'Bearer',
        client_id: '<cognito client ID>',
        token_key: 'access_token',
        grant_type: 'authorization_code',
        endpoints: {
            user: {
                method: 'post'
            }
        }
    }
}

Current flow...

  1. Enter credentials
  2. Redirected to /callback/ route
  3. Redirected to /my-account/ route
  4. Code on /my-account/ route attempts to call https://<cognito domain>.auth.<cognito region>.amazoncognito.com/oauth2/token, which returns 400

a) The call is made as GET call, not a POST call
b) The body is missing all of the required parameters for that endpoint per Amazon's documentation

Before I go off and write my own plug-in, has anyone managed to get AWS Cognito working with this module? If so, is this something that could be added as a predefined scheme?

This question is available on Nuxt.js community (#c148)
question

Most helpful comment

Why was this closed? I would also vote for a feature request to include AWS Cognito as a provider that is predefined like Auth0 etc

All 3 comments

Why was this closed? I would also vote for a feature request to include AWS Cognito as a provider that is predefined like Auth0 etc

I was able to get it to work by changing the userinfo_endpoint to /userInfo instead of /token so the configuration would look something like:

strategies: {
    dev: {
        _scheme: 'oauth2',
        authorization_endpoint: 'https://<cognito domain>.auth.<cognito region>.amazoncognito.com/oauth2/authorize',
        userinfo_endpoint: 'https://<cognito domain>.auth.<cognito region>.amazoncognito.com/oauth2/userInfo',
        scope: ['openid', 'profile', 'email', 'phone'],
        response_type: 'token',
        token_type: 'Bearer',
        client_id: '<cognito client ID>',
        token_key: 'access_token'
    }
}

Its been over a year, is this still the best way to integrate Cognito and Nuxt Auth?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

essamamdani picture essamamdani  路  3Comments

amjadkhan896 picture amjadkhan896  路  3Comments

nikkanetiya picture nikkanetiya  路  3Comments

abegehr picture abegehr  路  4Comments

weijinnx picture weijinnx  路  3Comments