I'm running the php google drive api and I can authenticate the user just fine, but I want to store the user's permissionId and their email address into my database. the permissionid is easily accessible with
$service = new Google_Service_Drive($client);
...
$permissionID = $service->about->get()->getpermissionId();
but there isn't anything like getEmailAddress() Does google drive have a return for the email address or do I need to extend the scope and access it elsewhere?
currently my scope is https://www.googleapis.com/auth/drive
EDIT
just managed to do this by doing a get request with
https://www.googleapis.com/oauth2/v1/userinfo?access_token=
for people who have used this api before, is it better to store the PermissionId or the ID returned by the get request? I don't know what the difference between the two are
$service->about->get()->getUser()->getemailAddress();
This will give you the email address of the user that is authenticated with your app.
As KRR mentioned above, visit Google's Drive Api Reference Page for more functions. Usually if you want to get a property value it is in the form of get($propertyname)()
The answer CrudeCoder gave is correct for Drive API v2. For Drive API V3 use:
$service->about->get(array('fields' => 'user'))->getUser()->getemailAddress();
In V3 you need to specify the fields params.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With