Meteor 检索帐户github accesstoken

Meteor 检索帐户github accesstoken,meteor,github-api,Meteor,Github Api,我正在编写一个使用GithubAPI的第三方包。我现在正试图使用来自accounts github包的accessToken,以发出经过身份验证的github API请求 如何从帐户github检索accessToken?如果您是从服务器端执行此操作,则其操作如下: var user = Meteor.user().services.github.accessToken; Meteor.publish('account', function() { return Meteor.user

我正在编写一个使用GithubAPI的第三方包。我现在正试图使用来自
accounts github
包的
accessToken
,以发出经过身份验证的github API请求


如何从
帐户github
检索
accessToken

如果您是从服务器端执行此操作,则其操作如下:

var user = Meteor.user().services.github.accessToken;
Meteor.publish('account', function() {
    return Meteor.users.find({_id: this.userId},{fields:{services: 1}});
});
在客户端,这有点棘手,因为
services
字段没有发布。如果按以下方式运行发布方法,则可以发布它:

var user = Meteor.user().services.github.accessToken;
Meteor.publish('account', function() {
    return Meteor.users.find({_id: this.userId},{fields:{services: 1}});
});
我建议在创建用户时将
accessToken
与客户端上需要的任何其他内容一起存储在概要文件中

Accounts.onCreateUser(function(options, user) {
    if (options.profile)
        user.profile = options.profile;
    user.profile.github_accessToken = user.services.github.accessToken;
    return user;
});
然后,您可以使用
Meteor.user().profile.github\u accessToken
在客户端或服务器上访问
accessToken