Google Api get users Email Address

后端 未结 2 853
不知归路
不知归路 2021-01-24 08:39

I am using the Google Api PHP client to Log the user in. I want to get the Users Email address. I have the following code.

Scope:

$client->setScopes(\         


        
相关标签:
2条回答
  • 2021-01-24 08:47
    https://www.google.com/accounts/AuthSubRequest?next=http://www.example.com/index.php&scope=https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/analytics.readonly&secure=0&session=1 
    or
    https://www.google.com/accounts/AuthSubRequest?next=http://www.example.com/index.php&scope=email+https://www.googleapis.com/auth/analytics.readonly&secure=0&session=1
    

    both of above links works for me in php

    0 讨论(0)
  • 2021-01-24 09:01

    Setting the scope in an array does the job.

    $this->client->setScopes(array('https://www.googleapis.com/auth/analytics.readonly', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile'));
    
    0 讨论(0)
提交回复
热议问题