0
我正在編寫使用GitHub API的第三方包。我現在試圖使用accounts-github
包中的accessToken
來製作經過驗證的GitHub API請求。檢索帳戶-github accesstoken
如何從accounts-github
檢索accessToken
?
我正在編寫使用GitHub API的第三方包。我現在試圖使用accounts-github
包中的accessToken
來製作經過驗證的GitHub API請求。檢索帳戶-github accesstoken
如何從accounts-github
檢索accessToken
?
如果你從服務器上做側其如下:
var user = Meteor.user().services.github.accessToken;
在客戶端,它有點棘手,因爲services
領域尚未發佈。
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_accessToken
accessToken