[ASP.NET]GOOGLE OPEN ID 登入

使用GOOGLE OPEN ID登入相當的容易跟簡單,不需要太複雜的程式。

首先到https://accounts.google.com/ManageDomains註冊要使用的Domain。

註冊完以後記得要上傳GOOGLE給你的驗證檔案確認你是該Domain的所有者,接著再填入Target URL path prefix這欄位的資訊按下儲存就可以了。

接下來只要在要讓使用者登入的地方將連結改為

https://www.google.com/accounts/o8/ud? openid.ns=http://specs.openid.net/auth/2.0 &openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select &openid.identity=http://specs.openid.net/auth/2.0/identifier_select &openid.return_to=取得Request Token後導向的網址 &openid.realm=剛註冊的Domain &openid.mode=checkid_setup

這樣就可以嚕(return_to跟realm請自行更改),當使用者按下連結並授權登入以後,GOOGLE便會回傳相關的資訊到你剛剛request中openid.return_to所填的網址,而其中一段QueryString openid.identity就是使用者ID,接下來就可以利用這組ID進行後續相關的應用了。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *