0

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!

4

1 回答 1

1

当您从刷新令牌中获取访问令牌时,该访问令牌本身就是一个凭证,之后没有交换过程。在凭证中,有: 1. 访问令牌 2. 刷新令牌。并且您获得凭证以交换授权代码,而不是访问令牌。因此,在您的代码中,在尝试获取访问令牌以交换访问令牌的过程中发生了错误。

于 2013-06-12T16:38:52.993 回答