I am using the YouTube api v3 to retrieve a list of videos using the example at https://developers.google.com/youtube/v3/code_samples/php#retrieve_my_uploads
I open
Took me ages to work this out as I couldn't find any examples on how to do this easily.
It turned out that I need to create a POST request to get an access code and refresh token and this was achieved with using Curlfrom the command line
url --data "code=AUHROISATON_CODE&client_id=CLIENT_ID.apps.googleusercontent.com&client_secret=CLINET_SECRET&redirect_uri=http://www.example.com&grant_type=authorization_code" https://accounts.google.com/o/oauth2/token
After a few errors such as 'Missing grant_type', 'Invalid code' it now works.
I revoked access to the app, ran the following GET request (taken from https://developers.google.com/accounts/docs/OAuth2WebServer#formingtheurl) to get the code and was able to use the code in the above Curl statement
https://accounts.google.com/o/oauth2/auth? scope=https://www.googleapis.com/auth/youtube& state=security_token%3D138r5719ru3e1%26url%3Dhttps://oa2cb.example.com/myHome& redirect_uri=https%3A%2F%2Foauth2-login-demo.appspot.com%2Fcode&, response_type=code& client_id=812741506391.apps.googleusercontent.com& approval_prompt=force