Я работаю над приложением Angular 8, которому требуется получить токен от Azure B2 C, а затем вызвать. NET CORE Web API. Я следую http://about-azure.com/using-azure-ad-b2c-with-angular-8/ Учебник. У меня есть Azure Приложение, одно для промежуточного программного обеспечения (веб-API) и второе для Angular.
Я получаю ошибку перенаправления, когда нажимаю «логин» с Angular.
https://localhost/#error=redirect_uri_mismatch&error_description
Я считаю, что произошла ошибка при перенаправлении URL-адреса приложения Web API, как показано на следующем экране. Я выполнил следующие действия из вышеприведенного руководства
Приложение веб-API включено Azure
![enter image description here](https://i.stack.imgur.com/Z6bLX.png)
Angular Приложение включено Azure
![enter image description here](https://i.stack.imgur.com/BUU0E.png)
Компонент приложения
<code>import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { OAuthService, NullValidationHandler } from 'angular-oauth2-oidc';
import { authConfig, DiscoveryDocumentConfig } from './auth.config';
@Component({
selector: 'app-root',
template: `
<h1 *ngIf="!claims">
Hi!
</h1>
<h1 *ngIf="claims">
Hi, {{claims.given_name}}!
</h1>
<h2 *ngIf="claims">Your Claims:</h2>
<pre *ngIf="claims">
{{claims | json}}
Логин Выйти API Call Ответ: {{message | json}} `, styles: []}) класс экспорта AppComponent {constructor (private http: HttpClient, private oauthService: OAuthService) {this.configure (); this.oauthService.tryLoginImplicitFlow (); } сообщение: строка; publi c getMessage () {this.http.get ("https://localhost: 5001 / api / values", {responseType: 'text'}) .subscribe (r => {this.message = r console.log ( "message:", this.message);}); } publi c login () {this.oauthService.initLoginFlow (); } publi c logout () {this.oauthService.logOut (); } publi c getимпланты () {let притязания = this.oauthService.getIdentityClaims (); вернуть претензии; } private configure () {this.oauthService.configure (authConfig); this.oauthService.tokenValidationHandler = new NullValidationHandler (); this.oauthService.loadDiscoveryDocument (DiscoveryDocumentConfig.url); }}
.WEB API развертывание
![enter code here](https://i.stack.imgur.com/HYByZ.png)
namespace App.Core.API.Controllers
{
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class HomeController : ControllerBase
{
[HttpGet]
public IActionResult GetAsync() => Ok("Hello, World");
}
}