Get Userinfo from Google OAuth 2.0 PHP API

前端 未结 3 1988
天涯浪人
天涯浪人 2020-12-09 08:56

I am trying to use Google Oauth API to get userinfo. It works perfectly for Google Plus API but I am trying to create a backup in case the user doesn\'t have google plus acc

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 09:37

    Was missing scopes

    $client->setScopes(array('https://www.googleapis.com/auth/userinfo.email','https://www.googleapis.com/auth/userinfo.profile'));
    

    Works like a charm now!

提交回复
热议问题