如何获取刷新令牌以使用javascript或python

时间:2017-05-16 12:35:37

标签: javascript python oauth-2.0 google-oauth

我正在尝试为当前令牌过期的客户端获取新的访问令牌。我看过一些使用ruby的例子和一些使用javascript的例子但是noni似乎可以让它们中的任何一个工作。我必须能够在javascript或python中执行此操作,因为它将存在于lambda中,而lambdas可以使用非常少的语言。我似乎无法得到任何我发现因某些原因而工作的例子,并认为它必须是一些东西。

var GoogleTokenProvider = require('refresh-token').GoogleTokenProvider;

var tokenProvider = new GoogleTokenProvider({
refresh_token: '1/***************************Xk', 
client_id:     '930******858-t8683rc*********v2i7efg5o7.apps.googleusercontent.com', 
client_secret: 'EM-u_cQJU*******bK16EUa'
});



// Retrieve tokens via token exchange explained above or set them:
oauth2Client.setCredentials({
access_token: 'ya29.Gl**********msfwAwXBWU-EyGWu******************Z2HK9XmBIah20sCT6*************Htm9hPEDBIaml8VW',
refresh_token: '1/************************xMXk',
// Optional, provide an expiry_date (milliseconds since the Unix Epoch)
//   expiry_date: (new Date()).getTime() + (1000 * 60 * 60 * 24 * 7)
});


 oauth2Client.refreshAccessToken(function(err, tokens) {
// your access_token is now refreshed and stored in oauth2Client
// store these new tokens in a safe place (e.g. database)
console.log(oauth2Client);
console.log("new",tokens);
}); 

任何帮助都会受到赞赏,因为这是阻止我再次推进这个项目的唯一因素,我必须在时间限制上解决这个问题。我在Javascript中有一些其他的例子我可以提供任何身体想要看到它们。我对pyton真的很陌生,所以我还没有深入研究过这个问题,但那就是我对这部分的主要功能是什么。

0 个答案:

没有答案
相关问题