Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAccessToken进不去 #30

Open
callmesoul opened this issue Feb 22, 2017 · 2 comments
Open

getAccessToken进不去 #30

callmesoul opened this issue Feb 22, 2017 · 2 comments

Comments

@callmesoul
Copy link

callmesoul commented Feb 22, 2017

`
get_redrict:function (req,res) {

    console.log(req.query.code);

    client.getAccessToken(req.query.code, function (err, result) {

        console.log(req.query.code);

        var accessToken = result.data.access_token;

        var openid = result.data.openid;

        client.getUser(openid, function (err, user) {

            console.log(user)

        });

    });

},

`
第一个console.log(req.query.code);能打印,之后旧没反应了

@callmesoul
Copy link
Author

这是实例化代码

`var client = new OAuth(wechat.appID, wechat.appSecret, function (openid, callback) {
// 传入一个根据openid获取对应的全局token的方法
// 在getUser时会通过该方法来获取token
db.token.findOne({where:{openid:openid}}).then(function (token) {
return callback(null,token);
})
}, function (openid, token, callback) {
// 请将token存储到全局,跨进程、跨机器级别的全局,比如写到数据库、redis等
// 这样才能在cluster模式及多机情况下使用,以下为写入到文件的示例
// 持久化时请注意,每个openid都对应一个唯一的token!
db.token.upsert({access_token:token.access_token,expires_in:token.expires_in,refresh_token:token.refresh_token,openid:token.openid,scope:token.scope,create_at:token.create_at},{where:{openid:token.openid}}).then(function (result) {

})

});`

@qinghechaoge
Copy link

我也遇到这个问题 你那怎么解决的啊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants