Coder Social home page Coder Social logo

meteor-accounts-wechat-mp's People

Contributors

seanjsong avatar xyx2011 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

meteor-accounts-wechat-mp's Issues

cordova integration

Have you been able to integrate the plugin with Cordova ?
You give reference to boxfish:meteor-wechat (which seems totally broken), so I thought maybe you tried it before.

server.js中对HTTP.get的返回值没有做好出错处理

在getTokenResponse()和getIdentity()中都有HTTP.get查询微信接口,返回值是这样处理的:

        if (response.error) // if the http response was an error
            throw response.error;
        if (typeof response.content === "string")
            response.content = JSON.parse(response.content);
        if (response.content.error)
            throw response.content;

Meteor的文档是这样说的:

When run in synchronous mode, either result is returned from the function, or error is thrown.

Contents of the result object:

statusCode Number
Numeric HTTP result status code, or null on error.
content String
The body of the HTTP response as a string.
data Object or null
If the response headers indicate JSON content, this contains the body of the document parsed as a JSON object.
headers Object
A dictionary of HTTP headers from the response.

所以:

  • response应该没有error属性
  • response.content应该总是String类型的,不需要判断
  • response.content.error不存在

比如我用一个过期的access token查询https://api.weixin.qq.com/sns/userinfo接口,结果如下:

curl -v https://api.weixin.qq.com/sns/userinfo\?access_token\=w1INhgRMe11Y_MEXe5_BBgYrxFNzBy9nXgfhaEqtz5n1AVjj7CAB0zwIp08dahb5zTA40yJFE7yFptzFt11WvPcdL-rjP9chlwWfEnRdihQ\&openid\=owKOmuAhaxPcr8Vq0eWJ6H2tCgu0\&lang\=zh-CN
*   Trying 103.7.30.34...
* TCP_NODELAY set
* Connected to api.weixin.qq.com (103.7.30.34) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: mp.weixin.qq.com
* Server certificate: GeoTrust SSL CA - G3
* Server certificate: GeoTrust Global CA
> GET /sns/userinfo?access_token=w1INhgRMe11Y_MEXe5_BBgYrxFNzBy9nXgfhaEqtz5n1AVjj7CAB0zwIp08dahb5zTA40yJFE7yFptzFt11WvPcdL-rjP9chlwWfEnRdihQ&openid=owKOmuAhaxPcr8Vq0eWJ6H2tCgu0&lang=zh-CN HTTP/1.1
> Host: api.weixin.qq.com
> User-Agent: curl/7.51.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: text/plain
< Date: Fri, 28 Apr 2017 01:11:07 GMT
< Content-Length: 84
<
* Curl_http_done: called premature == 0
* Connection #0 to host api.weixin.qq.com left intact
{"errcode":42001,"errmsg":"access_token expired, hints: [ req_id: O.VrUa0867ns88 ]"}%

在getIdentity()的代码中,response.content就是{"errcode":42001,"errmsg":"access_token expired, hints: [ req_id: O.VrUa0867ns88 ]"},经过JSON.parse后正常返回。从这样parse得到的对象里再去取nicknameheadimgurl等属性,结果都是undefined。

这段对HTTP.get返回值的处理代码,在一切正常时确实能返回正确的结果,出错时却并不能抛出异常。

我们在实际部署中遇到过几次这样的情况,用户登录后创建的账户中profile里只有openId等属性,而没有用户个人信息的nickname等属性。

Meteor.loginWithWechatMP callback is never called

I have been playing around with the lib and found a couple of problems.
First of all, the package zhaoyao91:short-oauth-state should be made mandatory, I knocked my head on the wall to find out why weixin was refusing my requests.

Another problem is that my callback in Meteor.loginWithWechatMP(function callback(err) {
// never executed...
});

I does work for well for the open platform with loginWithWechat().

At the moment I directly hacked the Oauth package overwritting OAuth.getDataAfterRedirect to detect the return from weixin. It works but it's definitely not a good practice...

Is the callback working for you ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.