2016-02-05 25 views
0

,同時瞭解谷歌的oauth2,我看到了實現的oauth2數據來自谷歌後授權

選項1)兩個選項使用PHP客戶端庫服務器上 例如本地安裝 - 使用JavaScript,AJAX http://phppot.com/php/php-google-oauth-login/

選項2) ,PHP &谷歌平臺庫(直接從CDN) 示例 - http://w3lessons.info/2015/05/19/google-oauth-2-0-ajax-login-using-jquery-php-mysql/

我已經能夠實現兩者。不過,我有以下問題:

問題1) 在選項1 [$profile = $this->client->verifyIdToken()->getAttributes();]給了我賬戶資料所僅email[email] & google ID[sub]包含。

輸出:的$profile

Array 
(
    [envelope] => Array 
     (
      [alg] => R256 
      [kid] => ca6f0ece055ffa823454e56da 
     ) 

    [payload] => Array 
     (
      [iss] => accounts.google.com 
      [at_hash] => e5l-tvQpWQ 
      [aud] => 8pps.googleusercontent.com 
      [sub] => 186524872 
      [email_verified] => 1 
      [azp] => 1go.apps.googleusercontent.com 
      [email] => [email protected] 
      [iat] => 14543 
      [exp] => 14543 
     ) 

) 

在選項2 [var profile = googleUser.getBasicProfile();]給我其中包含全名&對谷歌ID &電子郵件

的頂部輪廓圖片鏈接配置文件數據有什麼功能,可以得到我的配置文件名&使用選項1的圖片鏈接(僅基於PHP的實現)

問題2)對於op

<div class="g-signin2" data-longtitle="true" data-onsuccess="Google_signIn" data-theme="light" data-width="200"/> 

回答

0

問題1:重刑2我怎麼可以修改默認的「谷歌按鈕」標誌被谷歌通過DIV發送$簡介[「有效載荷」現在有一個額外的鍵名爲圖片,它的值是一個個人資料圖片的網址。

問題2:您可以使用自定義登錄按鈕的屬性數量有限:數據範圍,寬度,高度,數據長標題,數據主題,數據成功和數據失敗。數據範圍用於請求許可範圍。 data-longtitle會分別使用true或false(默認)值來確定是要顯示「用Google登錄」還是「登錄」。數據主題的值是明暗的。而數據訪問和數據失敗則需要在成功/失敗登錄嘗試時調用js函數。

除此之外,你必須做一些閱讀來真正定製按鈕在這裏:https://developers.google.com/identity/sign-in/web/build-button#customizing_the_automatically_rendered_sign-in_button_recommended