I have implemented oauth2 with Google, using the googleapis/google-api-php-client API client in PHP and have got it working with the sign in scope "profile". I want to use incremental authorization, such that some time after the user has logged in I can add the YouTube scope "https://www.googleapis.com/auth/youtube.force-ssl" so I can gather info on YouTube creators comments. Every example I can find only goes as far as saying that you need to add the following single line of code:
$client->setIncludeGrantedScopes(true);
I've done that, but what do I do after I have authenticated the user for login, with that, and I now want to actually request the YouTube scope? Do I just run them through an additional oauth request? If so, how do I link the login with the youtube scope or is there a different procedure?
I can request both profile and the YouTube scopes, during the initial oauth login, without issue but I would rather the user login with the profile scope and then later add the YouTube scope. The main reason is that even though I am just using this to read comments, the scope itself pretty much gives the site the ability to do anything related to youtube and I don't want to scare off the user when they initially login and are prompted to approve such a high level scope.
If someone could point me to or show me a full example in PHP of this process I would be extremely grateful as I have been struggling with this for some time.
Thanks!
Nick