【发布时间】:2017-06-08 02:45:46
【问题描述】:
我使用带有资源服务器和授权服务器的 spring boot 开发了用于 OAuth2 的 Rest API。我可以使用 cURL、POSTMAN Rest 客户端成功获取令牌,并且可以使用 OAuth 提供的令牌请求授予的服务。现在,我需要知道如何使用 angular2 传递 OAuth2 client_id、secret_id。 我将请求传递为 getOAuthToken(clientCredintial):Observable {
var body = `username=admin&password=nex1234`;
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
let response = this.http.post(`${AppSettings.BACK_ENDPOINT}/oauth/token`,body,{ headers: headers });
let oauthTokenItems = response.map(mapOAuthTokenItems);
return oauthTokenItems;
} 但我在浏览器上遇到异常 选项http://localhost:8080/rwsweb/oauth/token 401 ()
oauth-token:1 XMLHttpRequest cannot load http://localhost:8080/rwcweb/oauth/token. Response for preflight has invalid HTTP status code 401
error_handler.js:47 EXCEPTION: Response with status: 0 for URL: null
ErrorHandler.handleError @ error_handler.js:47
next @ application_ref.js:272
schedulerFn @ async.js:82
Subscriber.js:227 未捕获响应 {_body: ProgressEvent, status: 0, ok: false, statusText: "", headers: Headers...}enter code here
【问题讨论】:
标签: angular spring-security spring-security-oauth2