I am trying to use the YouTube YouTube data API with PHP based on the Google documentation here: https://developers.google.com/youtube/2.0/developers_guide_protocol_oauth2#OAuth2_Refreshing_a_Token . My problem occurs when authenticating with OAuth. I use the following authorization URL, which is identical to what the docs say, except for my uri redirection and application key, obviously.
$this->authorizationUrl = 'https://accounts.google.com/o/oauth2/auth?'; $this->authorizationUrl .= 'client_id=' . $this->applicationKey . '&'; $this->authorizationUrl .= 'redirect_uri=' . $this->redirect_uri . '/account.php?action=youtube_oauth&'; $this->authorizationUrl .= 'scope=https://gdata.youtube.com&'; $this->authorizationUrl .= 'response_type=code&'; $this->authorizationUrl .= 'access_type=offline';
Then, as the docs say, I find the following:
$curl_options = Array( CURLOPT_POSTFIELDS => Array( 'code' => $code, 'client_id' => $this->applicationKey, 'client_secret' => $this->applicationSecret, 'redirect_uri' => $this->redirect_uri . '/account.php?action=youtube_oauth', 'grant_type' => 'authorization_code' ), CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => 'https://accounts.google.com/o/oauth2/token' );
However, my answer never gives me a refresh_token, as in their documentation. I just get the other three response elements.
Some questions like this one: Get the refresh google api token , said they use assert_prompt = force, but this does not work and the goal completely wins is to have access_type = missing.
Any ideas as to why I am getting a valid answer with 3 of 4 response elements?
joshholat
source share