我正在关注此软件包:https://github.com/googleads/google-ads-php .在这里他们说我需要运行这个页面:
https://github.com/googleads/google-ads-php/blob/main/examples/Authentication/GenerateUserCredentials.php
到终端。
我就这样做了:
php /locaation of the fie/GenerateUserCredentials.php
之后,我可以得到一个链接,它是这样的:
https://accounts.google.com/o/oauth2/v2/auth?response_type=code&access_type=offline&client_id=535777736006-d1rp8msevnls2pmihk7b8l23j3vra7duh.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fcallback&state=4e23ce963534701029c1a22d2de7848d034d8b0b0&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadwords
(以上链接为演示目的)
所以,当我点击这个链接,我重定向到我的谷歌帐户,并给予访问他们,之后我重定向回到这个下面的URL:
请输入您的密码,然后点击这里返回上一页。请输入您的密码。
在这里,您可以看到我有两个参数,分别是state和code。
现在我的问题是如何使用此URL获取访问令牌和刷新令牌?
1条答案
按热度按时间e4eetjau1#
在这里,您可以看到我有两个参数,分别是state和code。
下面是一个来自google-ads-php源代码的例子(打开链接查看完整的例子/代码):