Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AdWords API PHP OAuth2 Web流_Php_Oauth 2.0_Google Ads Api - Fatal编程技术网

AdWords API PHP OAuth2 Web流

AdWords API PHP OAuth2 Web流,php,oauth-2.0,google-ads-api,Php,Oauth 2.0,Google Ads Api,更新:这实际上会刷新Oauth2令牌。我的代码中有一个错误导致它失败。为了帮助其他人,我决定不删除它 我在使用AdWords API(v201702)中的刷新令牌重新生成oauth2tokens时遇到问题。使用找到的代码示例,我能够在用户授予访问权限后对其进行身份验证,但我不知道如何在原始令牌过期后使用刷新令牌生成新的oauth2token。我向API发出请求的唯一方法是不断地重新验证。这是我现在掌握的代码: $oauth2Token = (new OAuth2TokenBuilder())

更新:这实际上会刷新Oauth2令牌。我的代码中有一个错误导致它失败。为了帮助其他人,我决定不删除它

我在使用AdWords API(v201702)中的刷新令牌重新生成oauth2tokens时遇到问题。使用找到的代码示例,我能够在用户授予访问权限后对其进行身份验证,但我不知道如何在原始令牌过期后使用刷新令牌生成新的oauth2token。我向API发出请求的唯一方法是不断地重新验证。这是我现在掌握的代码:

$oauth2Token = (new OAuth2TokenBuilder())
 ->withClientId($clientId)
 ->withClientSecret($clientSecret)
 ->withRefreshToken($refreshToken)
 ->build();
$adWordsSession = (new AdWordsSessionBuilder())
 ->withOAuth2Credential($oauth2Token)
 ->withDeveloperToken($developerToken)
 ->build();
当我试图使用adWordsSession进行API调用时,我收到了一个错误的请求。$oauth2Token不包含accessToken,因此我假设它没有正确生成。有人能帮忙吗