Angular 9 throw error 'missing required parameter' on requesting token from Azure B2C

送分小仙女□ 提交于 2020-05-16 22:36:28

问题


I am working on Angular 9 application with .NET CORE Web API 3.1 application. I configure Angular client App to authenticate using Auth 2.0 Azure B2C and angular-oauth2-oidc in Angular. I am getting error on requesting token and CORS Policy in Browser. Screen shot at the end

{"error":"invalid_request","error_description":"AADB2C90083: The request is missing required parameter: grant_type.\r\nCorrelation ID: xxxx5370-695b-4f09-b583-e67600000000\r\nTimestamp: 2020-05-07 15:23:06Z\r\n"}

I configure postman and it successfully redirect to Microsoft login screen and return token. I have create Secret and grant permission client application to use Web API application in Azure under API Permission Section

Component

import { Component } from '@angular/core';
import { OAuthService, JwksValidationHandler } from 'angular-oauth2-oidc';
import { authConfig } from './auth.config';
import { JwksValidationHandler } from 'angular-oauth2-oidc-jwks';

@Component({
 selector: 'app-root',
 templateUrl: './app.component.html',
 styleUrls: ['./app.component.css']
   })
 export class AppComponent {  
   title = 'Angular9B2CAuthApp';

 constructor(private oauthService:OAuthService){
    this.configureSingleSignOn();
  }

 configureSingleSignOn(){
   this.oauthService.configure(authConfig);
   this.oauthService.tokenValidationHandler = new JwksValidationHandler();
   this.oauthService.loadDiscoveryDocumentAndTryLogin();
}

 login(){
    this.oauthService.initImplicitFlow();
 }

 logout(){
   this.oauthService.logOut();
 }
}

Auth.cofig

Not really sure what I am missing from puzzle. I have just realize one thing in Azure, i cannot run user flow of signin and out policy

Please refer to redirect URIs... I believe there is something missing?

I have found another issue, I am not sure if it inter link of what I am trying to solve it

来源:https://stackoverflow.com/questions/61661886/angular-9-throw-error-missing-required-parameter-on-requesting-token-from-azur

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