【问题标题】:MacOS Xamarin - Google OAuth Callback working in debug and not in releaseMacOS Xamarin - Google OAuth 回调在调试而不是发布中工作
【发布时间】:2018-02-06 21:52:10
【问题描述】:

我在用 c#/Xamarin 编写的 MacOS 应用程序中的 OAuth 进程的回调中遇到错误。

我正在使用 Clancey.SimpleAuth 来简化流程 (https://github.com/Clancey/SimpleAuth)

基本上在我的代码中,我有一个简单的身份验证,例如:

var scopes = new[]
{
  "https://www.googleapis.com/auth/userinfo.email",
  "https://www.googleapis.com/auth/userinfo.profile"
};
var api = new GoogleApi("google",
   "clientid",
   "clientsecret")
{
    Scopes = scopes,
};

var account = await api.Authenticate();

问题很简单: 当我调试一切正常时,库接受回调,使用秘密挑战等。

在发布时,我收到此错误:

2018-02-06 22:48:38.278 MyAppName[2789:37686] -[SimpleAuth_Native_CallBackHelper UrlHandleEvent:event:replyEvent]: unrecognized selector sent to instance 0x604000c340a0
2018-02-06 22:48:38.279 MyAppName[2789:37686] -[SimpleAuth_Native_CallBackHelper UrlHandleEvent:event:replyEvent]: unrecognized selector sent to instance 0x604000c340a0
2018-02-06 22:48:38.279 MyAppName[2789:37686] -[SimpleAuth_Native_CallBackHelper UrlHandleEvent:event:replyEvent]: unrecognized selector sent to instance 0x604000c340a0
2018-02-06 22:48:38.279 MyAppName[2789:37686] -[SimpleAuth_Native_CallBackHelper UrlHandleEvent:event:replyEvent]: unrecognized selector sent to instance 0x604000c340a0

调试和发布配置之间可能有什么问题/区别?

提前致谢

【问题讨论】:

  • 这是一个静态类吗?
  • 在您的发布配置中,关闭链接行为 (Don't Link) 并重新测试。
  • @hichame.yessou 它使用静态类 SimpleAuth.NativeSafariAuthenticator.Activate(); SushiHangover 它已经“不链接”了
  • 不确定是不是这样,但是如果没有引用静态类,jit编译器由于优化原因不会加载类,我会尝试删除静态,关闭链接行为@SushiHangover 说并取消选中项目构建面板的优化代码
  • 试过没有代码优化,还是不行。你知道我可以使用其他任何库吗?

标签: c# oauth google-api xamarin.mac


【解决方案1】:

没有办法用旧的“组件”修复它

我切换回“Google 官方”包:

            var credential = await Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsync(
            new Google.Apis.Auth.OAuth2.ClientSecrets
            {
                ClientId = "IDIDIDIDIDIDgesmfcm.apps.googleusercontent.com",
                ClientSecret = "csL-.........."
            },
                      new[] { "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile" },
            "user",
                CancellationToken.None, new FileDataStore("AppStore"));

            Utils.Log("Logged as " + credential.UserId);
            //TOKEN USE

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-07
    • 2014-11-30
    • 2015-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多