2017-10-03 1 views
0

私はidentityserverからunauthorized_client得るのですか理由を理解するように見えることはできません。私は、Web APIのAngular 4 UIとasp.netコアでoidc-clientを使用します。クライアントが返却されるたびにIDサーバに接続できません。unauthorized_clientです。Identityserver暗黙のフローunauthorized_client

これが登録されているクライアントである:

import { Injectable, EventEmitter } from '@angular/core'; 
import { Http, Headers, RequestOptions, Response } from '@angular/http'; 
import { Observable } from 'rxjs/Rx'; 

import { UserManager, User } from 'oidc-client'; 
import { environment } from '../../../environments/environment'; 

const settings: any = { 
    authority: 'http://localhost:8200/oauth', 
    client_id: 'EStudent', 
    redirect_uri: 'http://localhost:63150/auth.html', 
    post_logout_redirect_uri: 'http://localhost:63150/index.html', 
    response_type: 'id_token token', 
    scope: 'openid profile UsersAPI', 

    silent_redirect_uri: 'http://localhost:63150/silent-renew.html', 
    automaticSilentRenew: true, 
    accessTokenExpiringNotificationTime: 4, 
    // silentRequestTimeout:10000, 

    filterProtocolClaims: true, 
    loadUserInfo: true 
}; 

@Injectable() 
export class AuthService { 
    mgr: UserManager = new UserManager(settings); 
    userLoadededEvent: EventEmitter<User> = new EventEmitter<User>(); 
    currentUser: User; 
    loggedIn = false; 
    authHeaders: Headers; 

    constructor(private http: Http) { 
     this.mgr.getUser().then((user) => { 
      if (user) { 
       this.loggedIn = true; 
       this.currentUser = user; 
       this.userLoadededEvent.emit(user); 
      } else { 
       this.loggedIn = false; 
      } 
     }).catch((err) => { 
      this.loggedIn = false; 
     }); 

     this.mgr.events.addUserLoaded((user) => { 
      this.currentUser = user; 
      this.loggedIn = !(user === undefined); 
      if (!environment.production) { 
       console.log('authService addUserLoaded', user); 
      } 
     }); 

     this.mgr.events.addUserUnloaded((e) => { 
      if (!environment.production) { 
       console.log('user unloaded'); 
      } 
      this.loggedIn = false; 
     }); 
    } 
} 

そして最後に、私はコールはこのようidentityserverします:

constructor(public oidcSecurityService: AuthService) { } 

ngOnInit() { 
    this.oidcSecurityService.mgr.signinRedirect(); 
} 

これは角における認証サービスです

new Client 
{ 
    ClientId = "EStudent", 
    ClientName = "EStudent", 
    AllowedGrantTypes = GrantTypes.Implicit, 
    RequireClientSecret = false, 
    AllowAccessTokensViaBrowser = true, 
    AllowedCorsOrigins = { "http://localhost:63150" }, 
    LogoutSessionRequired = false, 
    RequireConsent = false, 
    AllowedScopes = new List<string> 
    { 
     IdentityServerConstants.StandardScopes.OpenId, 
     IdentityServerConstants.StandardScopes.Profile, 
     "UsersAPI", 
    }, 
    AlwaysIncludeUserClaimsInIdToken = true, 
    RedirectUris = { 
     "http://localhost:63150/oauth.html" 
    }, 
    PostLogoutRedirectUris = { 
     "http://localhost:63150/", 
     $"{this._baseAddress}/index.html" 
    }, 
    AllowOfflineAccess = true, 
} 

送信されるリクエストは次のようになります。http://localhost:8200/oauth/connect/authorize?client_id=EStudent&redirect_uri=http%3A%2F%2Flocalhost%3A63150%2Fauth.html&response_type=id_token%20token&scope=openid%20profile%20UsersAPI&state=91ea5de6886a49a997704bbdb4beda0c&nonce=295e6bf737274ea18ee2f575c93d150b

+0

マークそれ – MJK

答えて

3

あなたIdentityServer Clientリクエストで使用されていることと一致しないredirectUriがあります。リクエストに

http://localhost:63150/oauth.html 

、あなたが使用します。

http://localhost:63150/auth.html 

が欠落oに注意してください。

+0

がよりstupier取得できませんでした...それを指摘してくれてありがとうをそれが唯一の間違いであれば、私は今夜を尽くす答えとして。 –

関連する問題