2015-02-05 82 views
1

我有一個使用Ember CLI 0.1.12的簡單而有效的應用程序。我使用Ember Simple Auth插件與Token身份驗證器和授權人。 https://github.com/jpadilla/ember-cli-simple-auth-tokenEmber Simple Auth(帶有令牌插件)不會將Token頭添加令牌

首先,我無法驗證,因爲我不知道服務器應該返回什麼。很多谷歌搜索後,我能弄清楚,服務器將返回這樣的事情:

{「的access_token」:「ToKeN123hEre」}

現在我能夠認證和會話工作。但是當我進行其他調用時,Authorization頭部不會出現在請求標頭中,所以服務器不可能知道該令牌。

這是我到目前爲止已經試過:

設置我environment.js文件:

ENV['simple-auth'] = { 
    crossOriginWhitelist: ['*'], 
    authorizer: 'simple-auth-authorizer:token', 
    routeAfterAuthentication: '/profile' 
}; 

ENV['simple-auth-token'] = { 
    serverTokenEndpoint: '/api0/auth', 
    identificationField: 'username', 
    passwordField: 'password', 
    tokenPropertyName: 'token', 
    authorizationPrefix: 'Bearer ', 
    authorizationHeaderName: 'Authorization', 
    headers: {} 
}; 

讓我的服務器使用CORS,並允許從任何來源認證頭和請求。

回答

1

我最終改變了「access_token」只是「令牌」,現在它的工作。

+1

由於Rails使用authenticate_with_http_token方法的方式,這是一個剛剛發佈到ember-simple-auth的新更改。在此處查看問題:https://github.com/simplabs/ember-simple-auth/issues/387 – bravely 2015-02-05 22:33:05

相關問題