简体   繁体   English

Ember oauth2身份验证问题

[英]Ember oauth2 Authentication issues

Get an [error="unauthorized", error_description="Full authentication is required to access this resource"] when trying to connect the ember app to oauth2 authenication service. 尝试将ember应用程序连接到oauth2身份验证服务时,获取[error =“ unauthorized”,error_description =“需要完全身份验证才能访问此资源”]。 Any suggestions will be greatly appreciated. 任何建议将不胜感激。 I have spend couple of days trying to fix this but to no avail. 我花了几天的时间试图解决此问题,但无济于事。

here is the code in app.js 这是app.js中的代码


         Ember.Application.initializer({
      name: 'authentication',
      initialize: function(container, application) {
         Ember.SimpleAuth.Authenticators.OAuth2.reopen({
                     makeRequest: function(credentials) {
                         credentials.client_id= 'rsweb-client';
                         credentials.client_secret= '123456';
                         credentials.scope='read';
return Ember.$.ajax({ type: "POST", url: 'http://127.0.0.1:8080/api/oauth/token', async: false, data:credentials,
success: function (data, textStatus, xhr){ Ember.run(function(){ resolve({username: data['pl-usr-nickname']}); }); }, error: function (xhr, status, error){ Ember.run(function(){ console.log(xhr.responseText); }); } }); } });
Ember.SimpleAuth.setup(container, application, { // @todo at version 0.1.2 of Ember-simple-auth, add container crossOriginWhitelist: ['http://127.0.0.1:8080'], // @todo remove when live // store: Ember.SimpleAuth.Stores.LocalStorage, authenticationRoute: 'login' }); } }); Here is the # The OAuth-secured REST Endpoint This uses the simple OAuth Resource Owner Password flow. Here is an example of how to acquired an access_token, and then use that access_token to update an application. ``` curl --noproxy localhost -X POST -vu rsweb-client:123456 http://127.0.0.1:8080/api/oauth/token -H "Accept: application/json" -d "password=password&username=user&grant_type=password&scope=read&client_secret=123456&client_id=rsweb-client"

This returns an token when i access from the command line tool. But not from the ember app.

Here is the request payload:

Content-Type application/x-www-form-urlencoded; charset=UTF-8 Accept */* Parameters application/x-www-form-urlencoded client_id rsweb-client client_secret 123456 grant_type password password password scope read username user

It looks like your auth server expects the client_id and client_secret as HTTP basic auth credentials while your authenticator sends them in the payload. 看起来您的身份验证服务器希望将client_id和client_secret作为HTTP基本身份验证凭据,而您的身份验证器会在有效负载中发送它们。 You'll have to add the Authorization header in the makeRequest method as defined eg here: http://tools.ietf.org/html/rfc2617 which would be a base64-encoding of "rsweb-client:123456". 您必须在如以下定义的makeRequest方法中添加Authorization标头,例如: http ://tools.ietf.org/html/rfc2617,它是“ rsweb-client:123456”的base64编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Oauth服务器/客户端进行Ember身份验证 - Ember authentication with Oauth server/client OAuth2是独立的身份验证/授权系统吗? - Is OAuth2 a stand alone authentication/authorization system? Ember-simple-auth,Torii和Facebook Oauth2的工作流程 - Workflow for Ember-simple-auth, Torii and Facebook Oauth2 使用Ember.js和Torii(oauth2)连接到github - Connecting to github with Ember.js and Torii (oauth2) 简单的ember-cli-simple-auth和oauth2项目 - Simple ember-cli-simple-auth and oauth2 project ember-simple-auth oauth2授权者问题 - ember-simple-auth oauth2 authorizer issue 使用ember-cli和ember-simple-auth设置客户端凭据OAuth2 - Setting up Client Credentials OAuth2 with ember-cli and ember-simple-auth 带有服务器端Google OAuth 2 Passport身份验证的Ember应用程序(节点) - Ember app with server-side Google OAuth 2 Passport authentication (Node) Django rest + ember simple auth身份验证器“ authenticator:oauth2”被拒绝恢复会话-无效 - Django rest + ember simple auth The authenticator “authenticator:oauth2” rejected to restore the session - invalidating 如何在Express中用OAuth2授权代码交换从客户端(Ember)收到的访问令牌? - How to exchange OAuth2 authorization codes for access tokens received from a client (Ember) in Express?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM