我想获取从我的应用登录的用户的所有谷歌私人连接.我启用了Google People和Google Plus API.我设置了凭证API密钥,客户端ID和客户端密钥.我正在尝试获取用户连接的URL是
https://people.googleapis.com/v1/people/me/connections?fields=connections&key=api_key&access_token=access_token
Run Code Online (Sandbox Code Playgroud)
另外,我正在使用图书馆passport-google-oauth来获取用户access_token.以上网址中是否有任何我遗漏的内容.
我的谷歌验证码是
// send to google to do the authentication
// profile gets us their basic information including their name
// email gets their emails
app.get('/auth/google', passport.authenticate('google', {
scope: ['profile', 'email','https://www.googleapis.com/auth/contacts.readonly', 'https://www.googleapis.com/auth/contacts']
}));
// the callback after google has authenticated the user
app.get('/auth/google/callback',
passport.authenticate('google', {
successRedirect: '/profile',
failureRedirect: '/'
}));
Run Code Online (Sandbox Code Playgroud) google-api google-api-nodejs-client passport-google-oauth google-people
我正在使用googleapisnpm 库授权使用 OAuth2 访问我的 Gmail 帐户以发送电子邮件。我正在使用以下代码(TypeScript)来做到这一点:
const oAuth2Client = new google.auth.OAuth2(
googleConfig.clientId,
googleConfig.clientSecret
);
oAuth2Client.setCredentials({
refresh_token: googleConfig.refreshToken
});
const accessTokenRetVal = (await oAuth2Client.refreshAccessToken()).credentials.access_token;
const accessToken = accessTokenRetVal || '';
Run Code Online (Sandbox Code Playgroud)
此代码有效,但我收到以下消息:
(node:8676) [google-auth-library:DEP007] DeprecationWarning: The `refreshAccessToken` method has been deprecated, and will be removed in the 3.0 release of google-auth-library. Please use the `getRequestHeaders` method instead.
Run Code Online (Sandbox Code Playgroud)
我在 Google、GitHubgoogleapis和 StackOverflow上搜索过该模块,但找不到任何有关该getRequestHeaders方法构成的文档。我试过调用getRequestHeaders,但它似乎没有返回credentials带有访问令牌的对象。
是否有关于getRequestHeaders在这种情况下应该如何使用的官方文档?
我正在尝试为具有 Node.js 后端的 Web 应用程序实现 Google 登录和 API 访问。Google 的文档使用platform.js客户端和google-auth-library服务器端的组合提供了两个选项:
auth2.signIn()在客户端和verifyIdToken()服务器上。)auth2.grantOfflineAccess()在客户端上,它返回一个我可以getToken()在服务器上传递的代码。)我需要两者:我想通过 Google 登录验证用户;而且,我想建立服务器授权,因此它可以同时代表用户的工作。
我无法弄清楚如何使用单个身份验证流程来做到这一点。我能得到的最接近的是按顺序执行这两项操作:首先使用 对用户进行身份验证signIn(),然后(根据需要)通过 进行第二次传递grantOfflineAccess()。这是有问题的:
理想情况下,有一些变体signIn()将离线访问添加到初始身份验证流程中,并将代码与通常的令牌一起返回,但我什么也没看到。帮助?
(编辑:我在其他地方收到的一些建议是只实现流程 #2,然后使用安全 cookie 存储某种用户标识符,我在每个请求中检查用户帐户。我可以看到这可以正常工作,但基本上意味着我正在运行自己的登录系统,这似乎会增加我在关键系统中引入错误的机会。)
javascript node.js google-oauth google-api-nodejs-client google-signin
我正在尝试使用 gcloud api 在谷歌云存储中重命名或移动文件夹。
一个类似的问题解释了如何删除文件夹: Delete folder in Google Cloud Storage using nodejs gcloud api
但是如何重命名文件夹?或移动到另一条路?
node.js google-api-nodejs-client gcloud-node firebase-storage
我看到有两个可用的库。我想知道有什么区别?它们都是由 Google 官方维护的吗?
我正在尝试构建一个响应gmail pubsub消息的电子邮件解析器.我目前能够接收和解析pubsub消息并解压缩historyId,但是我无法验证我对gmail api的请求.这就是我现在所拥有的:
//function defined outside the scope of the main function
//used to create auth client
function getAuthClient(event, callback) {
var GoogleAuth = require('google-auth-library');
var authFactory = new GoogleAuth();
authFactory.getApplicationDefault(function (err, authClient) {
if (err) {
console.log('Unable to get application default credentials.');
callback(err);
return;
}
// Create the oAuth scopes you need
if (authClient.createScopedRequired && authClient.createScopedRequired()) {
console.log('creating scoped client');
authClient = authClient.createScoped([
'https://mail.google.com/'
]);
}
callback(null, authClient);
});
}
exports.gmailParser = function gmailParser (event, callback) {
var path …Run Code Online (Sandbox Code Playgroud) node.js google-api-nodejs-client gmail-api google-oauth2 google-cloud-functions
我创建了一个Android应用程序,它从用户请求"Server auth code"并将其发送到Nodejs中的Backend.现在,我想使用GoogleSign In API对此令牌进行身份验证,并获取"access-token"和"refresh-token".
我可以在这里看到Java/Python中的示例代码,使用google提供的库:https://developers.google.com/identity/sign-in/web/server-side-flow
我试图为Nodejs找到一个类似的库,你能提供一个片段或一些包,这可以帮助我吗?
我的 Windows 机器没有管理员权限。我可以在没有管理员权限的情况下安装 NVM 吗?我尝试使用环境变量路径设置,但它在我的情况下不起作用。
node.js node-modules google-api-nodejs-client nodejs-stream alexa-sdk-nodejs
我是一名 Python 开发人员,但我现在正在从事的项目的情况迫使我在 Node.js 中找到解决方案
这是发送邮件的简单Python代码,但是,在nodejs中是否有像这样的谷歌应用程序引擎方式,而不使用像mailJet或sendGrid这样的中介服务?
def send(recipient, sender, subject, body):
isHTML=True
print("recep: "+recipient)
logging.debug(u'Sending mail {} to {}'.format(subject,
unicode(recipient)).encode(u'utf-8'))
message = mail.EmailMessage(
sender=sender,
subject=subject,
to=recipient
)
if isHTML:
message.html = body
else:
message.body = body
message.check_initialized()
message.send()
Run Code Online (Sandbox Code Playgroud)
感谢您的理解和帮助。
google-app-engine node.js google-api-nodejs-client google-cloud-platform
按照 google api 文档https://developers.google.com/sheets/api/quickstart/nodejs,无法找到使用 oauth2 客户端的刷新令牌来获取新令牌的方法。
医生说:
"The application should store the refresh token for future use and use the access token to access a Google API. Once the access token expires, the application uses the refresh token to obtain a new one."
如何使用 google oAuth2 客户端的刷新令牌获取新令牌?
到目前为止,我已经成功地使用了一个简单的帖子
const getTokenWithRefresh = async (refresh_token) => {
return axios
.post("https://accounts.google.com/o/oauth2/token", {
client_id: clientId,
client_secret: clientSecret,
refresh_token: refresh_token,
grant_type: "refresh_token",
})
.then((response) => {
// TODO save new token here
console.log("response", …Run Code Online (Sandbox Code Playgroud) google-api google-sheets node.js google-oauth google-api-nodejs-client
node.js ×7
google-api ×3
google-oauth ×2
android ×1
gcloud-node ×1
gmail-api ×1
javascript ×1
node-modules ×1