【问题标题】:Error 400: redirect_uri_mismatch when distributing Xamarin Forms App错误 400:分发 Xamarin Forms 应用程序时的 redirect_uri_mismatch
【发布时间】:2021-02-11 01:11:14
【问题描述】:

我正在尝试通过 Visual Studio 2019 中的 Google Play 商店分发我的 Xamarin Forms Android 应用。

我遵循 Microsoft 的本教程: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/publishing/publishing-to-google-play/?tabs=windows

我完成了设置 Google 开发者帐户以及在 google 开发控制台和 OAuth2 客户端中创建应用程序的步骤。

然后我在表单中输入了客户 ID 和客户密码并尝试注册。我没有被转发到授权页面,而是看到了这个错误: Error 400: redirect_uri_mismatch

不幸的是,我不能只将 uri 添加到 OAuth2 客户端,因为每次尝试注册按钮时端口都会更改。

那么,我该如何解决这个问题呢? 我可以以某种方式修复 Visual Studio/Xamarin Forms 使用的端口吗? 有完全不同的方法吗?

非常感谢您的帮助。

【问题讨论】:

    标签: xamarin.forms xamarin.android visual-studio-2019 google-developers-console google-play-developer-api


    【解决方案1】:

    您需要创建桌面应用凭据而不是 Web 应用才能从 Visual Studio 注册

    【讨论】:

      【解决方案2】:

      这里的问题是,当您尝试注册时,Visual Studio 会随机更改 IIS Express 端口号。要解决此问题,请打开文件:

      [项目名称].vs\config\applicationhost.config

      其中 [projectname] 是不带方括号的项目名称,并滚动到以下节点:

      <binding protocol="http" bindingInformation="*:12345:localhost" />
      

      其中“12345”是 IIS 分配给该站点的随机端口。删除星号 * 以便您只有:

      <binding protocol="http" bindingInformation=":12345:localhost" />
      

      对上述所有节点执行此操作。保存文件,然后重新打开 VS。分发到 Google Play,重新输入您的客户端 ID 和客户端密码,然后单击注册,现在应该会显示允许访问屏幕弹出窗口。

      【讨论】:

      • 感谢这个答案完成了这个问题的第一个答案!
      猜你喜欢
      • 2022-10-11
      • 1970-01-01
      • 1970-01-01
      • 2020-10-04
      • 1970-01-01
      • 1970-01-01
      • 2017-09-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多