使用从 GetRefreshToken 生成的 authoriseUrl 抛出 404 错误

Throwing 404 error with the authoriseUrl generated from GetRefreshToken

我正在尝试创建一个使用 DFP 服务的示例项目。 直到现在 : 仍在身份验证部分:

a) 已成功创建 clientId,同时在创建新的 Client Id 时已在 Google 开发人员控制台中检查已安装的应用程序选项。

b) 将 clientId、clientSecret 添加到 ads.properties。

注意:采用 dfp-axis-jars-and-examples-2.2.0.tar 并在其中进行更改[通过在 IDE 中导入项目]。

c) 我 运行 在 运行 GetRefreshToken 之后试图在浏览器中粘贴 authoriseUrl 时遇到了麻烦。

请在下方查找错误:

"The redirect URI in the request: urn:ietf:wg:oauth:2.0:oob can only be used by a Client ID for native application. It is not allowed for the 'WEB' client type. You can create a Client ID for native application in the Credentials section of the Google Developers Console."

我相信我在创建新的 ClientId 时选择了错误的 applicationType。 感谢输入。

关闭后查看 authoriseUrl,似乎我发送了错误的 redirectUrl。

我忘记复制粘贴在 GetRefreshToken 回调中创建客户端 ID 时生成的 redirectUrl 属性:

private static final String CALLBACK_URL = "https://www.example.com/oauth2callback";//"urn:ietf:wg:oauth:2.0:oob";

现在没有错误:).

上面的答案乍一看没有多大意义,但是,我通过简单地为 redirectUri 设置一个值就解决了这个问题。所以在我的 GetRefreshToken.php 文件中

$redirectUri = "http://same_url_as_the_one_listed_in_console";