【发布时间】:2015-05-11 03:08:22
【问题描述】:
我尝试设置我的 Android 应用程序以使用 OAuth 2.0 对我自己的服务器进行身份验证。我做了什么:
- 在 Google Developers Console 中创建 Web 应用程序(项目 X)。
- 在 Google Developers Console (Project X) 中使用调试密钥库(由我的应用程序使用)和我的应用程序的包名称创建一个 Android 应用程序。
- 使用 Web 应用程序客户端 ID 通过 GoogleAuthUtil.getToken() 获取令牌,其中范围是“audience:server:client_id:”+ Web 应用程序客户端 ID。
我得到的只是这个“未知”异常,在搜索 Stackoverflow 和 Google 时没有帮助我,我希望有人能指出我正确的方向。
除了上述步骤之外,我还需要采取其他步骤吗?即使是最小的提示也非常感谢!
编辑:
com.google.android.gms.auth.GoogleAuthException: Unknown
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at dalvik.system.NativeStart.run(Native Method)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at Android.Runtime.JNIEnv.CallStaticObjectMethod (IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00064] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1161
at Android.Gms.Auth.GoogleAuthUtil.GetToken (Android.Content.Context context, System.String accountName, System.String scope) [0x00000] in <filename unknown>:0
at MyProject.<chooserResult>b__3 () [0x00002] in MyProject\File.cs:171
--- End of managed exception stack trace ---
com.google.android.gms.auth.GoogleAuthException: Unknown
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at dalvik.system.NativeStart.run(Native Method)
EDIT2:
我在哪里使用了 GoogleAuthUtil.GetToken(Context, accName, googleAuthScope)
- 上下文是活动上下文
- accName 是帐户邮件地址
- googleAuthScope 是上述范围:“audience:server:client_id:”
【问题讨论】:
-
你能粘贴完整的日志跟踪吗
-
@Ranjith 我在上面的帖子中编辑了它。
-
另外代码也需要调试,..之前没提过
-
@Ranjith 我使用了这里的代码示例:android-developers.blogspot.de/2013/01/…
-
您找到解决方案了吗?我也遇到了同样的问题。
标签: android xamarin oauth-2.0 xamarin.android google-oauth