AWS cognito hosted UI returns no token and no error

北城余情 提交于 2020-06-17 10:32:23

问题


I have been struggling this for the past three days, please HELP i am desperate.

I am using Angular 8 and AWS cognito hosted ui, I have all my files and settings configured but no matter what i dont get the token back. The hosted UI takes in the user and i can see it in the user pool too. I have already RE-CHECKED all my pool-id etc. (I have added everything recommended in the docs like adding that extra code in polyfill.ts and "node" in tsconfig.app.json) I have not missed out on anything

As of now the only thing i see in my localstorage is amplify-redirected-from-hosted-ui: true

and the code in the redirected url http://localhost:4200/?code=47ea4b57-5506-441e-b0f7-1e7f38abfed0

My code: -

App.component.ts

import { Auth, Hub } from 'aws-amplify';

export class AppComponent {
  constructor() {
    const authListener = async ({ payload }) => {
      switch (payload.event) {
        case 'signIn':
        console.log('signIn')
          break;
        case 'signIn_failure':
          console.log('failure')
          break;
        case 'signUp':
          console.log('signup')
          break;
      }
    };
    Hub.listen('auth', authListener);
}

  private url = "<domain>/login?response_type=code&client_id=<id>&redirect_uri=http://localhost:4200/";

  login() {
    console.log('hello')
    window.location.assign(this.url);
  }
}


main.ts

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

  const oauth = {
    domain : 'https://test.amazoncognito.com', 
    scope : ['phone', 'email', 'profile', 'openid','aws.cognito.signin.user.admin'], 
    redirectSignIn : 'http://localhost:4200', 
    redirectSignOut :'http://localhost:4200',
    responseType: 'code'
}

Amplify.configure(awsconfig);
Auth.configure({
oauth
});

aws-exports.ts

const awsmobile = {
    "aws_project_region": "us-east-2",
    "aws_cognito_identity_pool_id": "us-east-2:777",
    "aws_cognito_region": "us-east-2",
    "aws_user_pools_id": "us-east-2_7QKIL",
    "aws_user_pools_web_client_id": "1nXXX",
    "oauth": {}

};


export default awsmobile;

来源:https://stackoverflow.com/questions/60861370/aws-cognito-hosted-ui-returns-no-token-and-no-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!