我已经设置了一个身份服务器3服务器,并且已经按照复数形式的课程进行设置。它似乎正在工作但是当我向服务器发送令牌请求时,我收到一个错误:
它表示无效的char,我有一段时间试图查看从服务器返回的内容。这是Angular 2的请求:
@Injectable()
export class TokenService {
callbackUrl = encodeURI(window.location.protocol + '/' + '/' + window.location.host + '/tokenCallback.html');
private _url = 'https://localhost:44328/identity/connect/authorize?' +
'client_id=ketogeniqapiclientimplicit&' +
'response_type=token&' + 'scope=ketogeniqapi&' +
'redirect_uri=' + this.callbackUrl ;
constructor(private http: Http) {
console.log('in token service')
}
getToken() {
console.log('token service: get token')
console.log('url = ' + this._url);
return this.http.get(this._url)
.map(response => response.json())
.catch(this.handleError);
}
private handleError(error: Response) {
console.error(error);
return Observable.throw(error.json().error || 'Server Error');
}
}
如果我从浏览器运行上图中的链接,我会收到来自身份服务器的消息:“客户端应用程序未知或未经授权。”
这是客户定义:
public static IEnumerable<Client> Get()
{
return new List<Client>() {
new Client
{
ClientName = "ketogeniqapiclient",
ClientId = "Ketogeniq (Client Credentials)",
Flow = Flows.ClientCredentials,
ClientSecrets = new List<Secret>()
{
new Secret(KetogeniqApiConstants.KetogeniqApiClientSecret.Sha256())
},
AllowAccessToAllScopes = true
},
new Client
{
ClientName = "ketogeniqapiclientimplicit",
ClientId = "Ketogeniq (Implicit)",
Flow = Flows.Implicit,
AllowAccessToAllScopes = true,
RedirectUris = new List<string>
{
XamlwareStsConstants.XamlwareStsAngular + "tokentCallback.html"
}
}
};
}