I am making a PHP application, that will use a single google drive account.
So as an administrator i first give permission to google drive account. When permissions are accepted, i save the refresh token in a database.
After than, in a different URL, that will be used by clients, i am trying to authenticate.
Next, I pull the refresh token from database, and then a make a post request to:
$url = "https://accounts.google.com/o/oauth2/token";
with parameters:
$post_data = array(
'client_id' => CLIENT_ID,
'client_secret' => CLIENT_SECRET,
'refresh_token' => $refreshToken,
'grant_type' => 'refresh_token' );
After a get successful response, I save the access_token but when i try to exchange it for credentials, i get this error Message:
An error occurred: Error fetching OAuth2 access token, message: '
Error processing OAuth 2 request
Error 500
'
Fatal error: Uncaught exception 'CodeExchangeException' in ...
Am I missing something here? Is the oauth flow i used correct?
Thanks in advance!