aws-sdk-net-extensions-cognito: Not able to get any OAuth or custom Scopes in Access Token

Hello:

I am writing an application using Vue as the frontend, and asp.net core web api as the backend.
I am using “Authorization code grant” only for now, will add PKCE later.

Yet the only scope I am able get from the returned access token is “aws.cognito.signin.user.admin”

Below is content is the Access Content Payload, replaced some info with ****

{
  "sub": "*************************",
  "device_key": "*************************",
  "cognito:groups": [
    "AIS_Test_Group"
  ],
  "iss": "https://cognito-idp.ap-southeast-1.amazonaws.com/*****************",
  "client_id": "*************************",
  "event_id": "bcc3b362-ed43-4551-a562-6671f2ec3f2f",
  "token_use": "access",
  "scope": "aws.cognito.signin.user.admin",
  "auth_time": 1564057907,
  "exp": 1564061507,
  "iat": 1564057907,
  "jti": "e68c081c-533e-4f57-88cd-263b06d752f7",
  "username": "hans"
}

Allowed OAuth Scopes is checked for “phone”, “email”, “openid”, “aws.cognito.signin.user.admin” and “profile” in App client settings for uesr pool.

For backend Web API we are using Authenticating with Secure Remote Protocol (SRP)

[HttpPost]
        [Route("SignInSPR")]
        public async Task<ActionResult<string>> SignInSPR(User user)
        {
            var provider = new AmazonCognitoIdentityProviderClient(new AnonymousAWSCredentials(),_region);
            var userPool = new CognitoUserPool(_AWS_UserPoolId, _appClientId, provider);
            var cognitoUser = new CognitoUser(user.Username, _appClientId, userPool, provider);

            AuthFlowResponse authResponse=null;
            authResponse = await cognitoUser.StartWithSrpAuthAsync(new InitiateSrpAuthRequest()
            {
                Password = user.Password
            }).ConfigureAwait(false);

            return Ok(authResponse);
        }

Yet, we are not able to get any OAuth scopes such as “openid” and “profile”, or any “custom scopes”

Please advice on how can we get “OAuth scope” and “custom scopes” Amazon Cognito Authentication Extension Library or do I need to use ASP.NET Core Identity Provider?

Thank

Hans

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 11
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Hi. Is there any update on this issue? Would be great to access the custom scopes.

Same issue, it’s a huge flaw of Cognito.

Needs review with the team. There were lot of open issues in the past which were closed due to inactivity.

Thanks, this is definitely still a problem that I am encountering.

This is still an issue. Any update?

To whoever gets into this issue, if the following descriptions match your situation,

  1. You do not want to use the hosted UI
  2. Yourself or your colleagues choose to use the client/server pattern, i.e., call AWS Cognito SDK on your server-side to generate token, then pass it to your web or native app.

Then, the answer is simply NO, YOU CANT.

Actually, many similar issues have been there for about three years. Of course, this is one of them.

Most of them are simply closed and locked because there is no recent activity.