微信登录-不接收令牌 [英] Wechat login - do not receive token

查看:489
本文介绍了微信登录-不接收令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是关注了亚伦·布鲁克纳(Aaron Bruckner)的示例中提到的所有内容.在启用和禁用布尔标志的情况下尝试使用checkSignature.

I just followed all the stuff which are mentioned in this example from Aaron Bruckner. Tried out with and without the boolean flag for enabling the checkSignature.

init API:

api = WXAPIFactory.createWXAPI(getContext(), WXEntryActivity.APP_ID,
            true);

发送寄存器:

api.registerApp(WXEntryActivity.APP_ID);

发送登录名:

SendAuth.Req req = new SendAuth.Req();
      req.scope = "snsapi_userinfo";
      req.state = "none";
      api.sendReq(req);

尝试登录时,我会从微信获取确认屏幕.当点击确认登录"时,我被重定向到我的应用程序,但是什么也没有发生.

When trying to login i get the confirmation screen from wechat. When hitting "Confirm Login" i get redirected to my app but nothing happens.

未调用WXEntryActivity.class-因此我没有收到任何令牌来继续进行身份验证.

The WXEntryActivity.class is not called - so i dont receive any token to proceed with my authentification.

签名设置为false时的日志:

D/MicroMsg.PaySdk.WXFactory: createWXAPI, appId = wx41XXXXXXXXX41, checkSignature = false
D/MicroMsg.SDK.WXApiImplV10: <init>, appId = wx41XXXXXXXXX41, checkSignature = false
D/MicroMsg.SDK.WXMsgImplComm: ignore wechat app signature validation
D/MicroMsg.SDK.WXApiImplV10: registerApp, appId = wx41XXXXXXXXX41
D/MicroMsg.SDK.WXApiImplV10: registerApp, appId = wx41XXXXXXXXX41
D/MicroMsg.SDK.WXApiImplV10: register app com.my.packagename.debug
D/MicroMsg.SDK.MMessage: send mm message, intent=Intent { act=com.tencent.mm.plugin.openapi.Intent.ACTION_HANDLE_APP_REGISTER (has extras) }, perm=co
D/MicroMsg.SDK.WXMsgImplComm: ignore wechat app signature validation
I/MicroMsg.SDK.WXApiImplV10: sendReq, req type = 1
D/MicroMsg.SDK.MMessageAct: send, targetPkgName = com.tencent.mm, targetClassName = com.tencent.mm.plugin.base.stub.WXEntryActivity
D/MicroMsg.SDK.MMessageAct: send mm message, intent=Intent { flg=0x18000000 cmp=com.tencent.mm/.plugin.base.stub.WXEntryActivity (has extras) }

签名为true时的日志基本相同,除了:

The Logs when signature is true are basically the same except:

D/MicroMsg.SDK.WXMsgImplComm: check signature:3XXXXXXXXX02eb30820254a00302010202XXXXXXXXXXXXXXXXXXXXXXXXX
D/MicroMsg.SDK.WXMsgImplComm: pass

我有正确的Application-Signature MD5,没有添加:到Wechat-Dev-Console以及packageName com.my.packaname.debug,因为我正在使用debug.keystore签名我的调试版本. WXEntryActivity在我的com.my.packagename.wxapi内部,并用exported标志注册在我的AndroidManifest.xml中. 我也为proguard-rules.pro添加了一条规则以确保安全:

I have the correct Application-Signature MD5 without : added to the Wechat-Dev-Console as well as the packageName com.my.packaname.debug as i am using my debug.keystore to sign my debug version. WXEntryActivity is inside my com.my.packagename.wxapi and is registered in my AndroidManifest.xml with the exported flag. Also i added a rule to proguard-rules.pro to be safe:

 -keep class com.tencent.mm.sdk.** {
      *;
  }

只是无法弄清楚为什么没有调用WxEntryActivityonCreateonResp来获取令牌.

Just can not figure out why the onCreate and onResp of the WxEntryActivity is not getting called to get the token.

推荐答案

找到解决方案:

问题是由程序包名称引起的.

Problem was caused by the package-name.

正使用两种 release 版本的构建变体& 调试, 我希望我的调试版本(在build.gradle中设置)的软件包名称为com.my.packagename.debug,因此在微信的管理中心中,我使用了com.my.packagename.debug. 问题是WxEntryActivity是通过反射调用的,而我的WxEntryActivity位于我的com.my.packagename.wxapi中.

As am using two build variants release & debug, I expected the packagename to be com.my.packagename.debug for my debug-build (which is setup in build.gradle) So in the Admin-Center of Wechat i used com.my.packagename.debug. Problem is that the WxEntryActivity is called via reflection and my WxEntryActivity is located in my com.my.packagename.wxapi.

因此无法找到该类,需要将其放入手动"包.debug.wxapi.

Therefore the class couldnt be found and needs to be put into a "manual" package .debug.wxapi.

因此,在使用发行版和调试时,您需要两个活动位于两个不同的程序包中.

So you need two Activities located in two different packages when using release and debug.

这篇关于微信登录-不接收令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆