【问题标题】:Configuring a custom port for the 'localhost' redirect URL in Google OAuth 2.0在 Google OAuth 2.0 中为“localhost”重定向 URL 配置自定义端口
【发布时间】:2014-05-12 20:28:13
【问题描述】:

我想在 Google Developer Console 中为“已安装应用”类的重定向 URL 配置自定义端口。

按照https://developers.google.com/accounts/docs/OAuth2InstalledApp 中的说明,事实证明这应该是可能的:

redirect_uri=http://localhost:9004&

转到控制台(“console.developers.google.com”)、“凭据”和“创建新客户端 ID”,我找不到输入自定义端口号的字段。有谁知道如何做到这一点?

谢谢!

【问题讨论】:

  • 对于已安装的应用,redirect_url 是固定的,可以是urn:ietf:wg:oauth:2.0:oobhttp://localhost,不能在控制台编辑,如果要使用端口,直接使用即可,如@987654325 @,它可以工作。

标签: google-oauth


【解决方案1】:

事实上,您阅读的文档已经回答了您的问题:

当您在 Google Developers Console 中创建客户端 ID 时,系统会为您创建两个 redirect_uri:urn:ietf:wg:oauth:2.0:oobhttp://localhost。您的应用程序使用的值决定了授权代码如何返回到您的应用程序。

http://localhost 向 Google 授权服务器发出信号,授权代码应作为查询字符串参数返回给客户端上的 Web 服务器。 您可以在不更改 Google Developers Console 配置的情况下指定端口号。

【讨论】:

  • 感谢您的帮助,这对我来说并不明显。
【解决方案2】:

我尝试了这个想法并且它有效。 在凭据中给出连续端口或可能的端口为

**Redirect URIs**
http://localhost:55738/YoutubeVideoList.aspx
http://localhost:8080/YoutubeVideoList.aspx
http://localhost:8081/YoutubeVideoList.aspx
http://localhost:8082/YoutubeVideoList.aspx
http://localhost:8083/YoutubeVideoList.aspx
http://localhost:8084/YoutubeVideoList.aspx

并且在调用身份验证过程时不要忘记使用端口(以上任何人)提供正确的redirectURI。

【讨论】:

    猜你喜欢
    • 2020-11-09
    • 2015-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-15
    相关资源
    最近更新 更多