2014-07-07 56 views
2

我們正試圖從的OpenID 2.0遷移至OAuth 2.0登錄(ID連接)從OpenID的遷移到OAuth 2.0登錄(ID連接)2.0

我們通過google docs OpenID 2.0 (Migration)

,我們已經是問題出發即openid_id在ID令牌請求中沒有返回

首先驗證請求:

https://accounts.google.com/o/oauth2/auth?client_id=xxxxxxxxxxxxxxx.apps.googleusercontent.com&response_type=code&scope=openid+email&redirect_uri=http://domain.local/customer/auth-callback&openid.realm=http://domain.local/customer&state=secrettoken 

當用戶被重定向回我們得到以下PARAMS:

'state' => 'secrettoken', 
'code' => 'codeforexchange', 
'authuser' => '0', 
'num_sessions' => '1', 
'session_state' => 'absasd951d57fcc1148f59b6b455ec86045a731c..1de3', 
'prompt' => 'none', 

然後我們就https://accounts.google.com/o/oauth2/token交換令牌,我們收到以下:

'access_token' => 'accesstoken', 
'token_type' => 'Bearer', 
'expires_in' => 3594, 
'id_token' => 'idtoken' 

當我們嘗試解析https://www.googleapis.com/oauth2/v1/tokeninfo ne上的令牌信息時ither openid_id或總和是存在於docs - Step 3: Map OpenID 2.0 identifiers to OpenID Connect identifiers

響應描述只是(ID令牌):

"issuer": "accounts.google.com", 
"issued_to": "xxxxxxxxx-xxxxxxx.apps.googleusercontent.com", 
"audience": "xxxxxxxxx-xxxxxxx.apps.googleusercontent.com", 
"user_id": "user_id", 
"expires_in": 3594, 
"issued_at": 1404741485, 
"email": "[email protected]", 
"email_verified": true 

任何人都知道爲什麼呢?

注:此「domain.local」以前使用通過OpenID 2.0登錄因此,我希望openid_id應退還(能夠識別用戶遷移從OpenID的2.0至OpenidConnect)

有類似的問題這不幸並沒有解決我的問題。

回答

0

According to this該子包含在ID令牌中。我假設openid_id也在那裏。

ID令牌是一個安全令牌,使用一個客戶端 時,以及潛在的其他請求的權利要求由授權服務器包含關於最終用戶的身份驗證 權利要求。 ID令牌是 ,表示爲JSON Web令牌(JWT)[JWT]。

+0

不幸的是,正如你在我們的問題中看到的 - 我們提供了id_token(我已經更新了我的問題,以便更清楚)。我想這是一個錯誤..: -/ – Tomor

+0

該死的。你可能已經看過[這個問題](http://stackoverflow.com/questions/22842475/migrating-google-openid-to-openid-connect-openid-id-does-not-match?rq=1) ,但如果沒有,它可能有幫助 – brocknz

+0

是的,我們做到了,但無論如何,謝謝你。 – Tomor

4

獲得id_token後,您必須解碼才能找到openid_id。 https://www.googleapis.com/oauth2/v1/tokeninfo在編碼請求數據中是否包含openid_id時,不會返回openid_id作爲響應。爲了驗證你可以在這裏解碼你的id_token; https://developers.google.com/wallet/digital/docs/jwtdecoder

+0

感謝您的回覆,我會以這種方式進行測試。 – Tomor

+0

如果我半天前才發現這個問題:/ Google也欺騙了我,給出了這個錯誤的迴應。 – olamedia