Node.js 谷歌联系API节点
我一直在浏览GoogleNodeJSAPI文档,但是我没有看到联系人API中列出的文档。我是否遗漏了一些内容,或者这些内容没有包含在模块中?根据Google联系人API的Google NodeJS API,下面的链接可能会帮助您:Node.js 谷歌联系API节点,node.js,google-contacts-api,google-api-nodejs-client,Node.js,Google Contacts Api,Google Api Nodejs Client,我一直在浏览GoogleNodeJSAPI文档,但是我没有看到联系人API中列出的文档。我是否遗漏了一些内容,或者这些内容没有包含在模块中?根据Google联系人API的Google NodeJS API,下面的链接可能会帮助您: 谷歌的NodeJS官方API不使用联系人API。他们使用People API。如果您需要访问“其他联系人”,则需要联系人API 如果您已经将Contacts API用于其他目的,则仍然可以使用来连接Contacts API,方法是在创建auth客户端后向Conta
谷歌的NodeJS官方API不使用联系人API。他们使用People API。如果您需要访问“其他联系人”,则需要联系人API 如果您已经将Contacts API用于其他目的,则仍然可以使用来连接Contacts API,方法是在创建auth客户端后向Contacts API发送请求。如果您不使用googleapis库,这可能是一种过度使用,最好使用其他答案建议的其他库 假设您已经拥有该用户的访问令牌(例如,如果您使用生成该令牌,则代码如下:
const {google} = require("googleapis");
const authObj = new google.auth.OAuth2({
access_type: 'offline',
clientId: process.env.GOOGLE_ID,
clientSecret: process.env.GOOGLE_SECRET,
});
在访问令牌过期之前自动刷新它
authObj.on('tokens', (tokens) => {
const access_token = tokens.access_token
if (tokens.refresh_token){
this.myTokens.refreshToken = tokens.refresh_token
// save refresh token in the database if it exists
}
this.myTokens.accessToken = tokens.access_token
// save new access token (tokens.access_token)
}
authObj.setCredentials({
access_token:this.myTokens.accessToken,
refresh_token:this.myTokens.refreshToken,
});
向联系人API发出请求:
authObj.request({
headers:{
"GData-Version":3.0
},
params:{
"alt":"json",
//"q":"OPTIONAL SEARCH QUERY",
//"startindex":0
"orderby":"lastmodified",
"sortorder":"descending",
},
url: "https://www.google.com/m8/feeds/contacts/default/full"
}).then( response => {
console.log(response); // extracted contacts
});
谢谢!你在api文档中哪里看到的?我在文档中没有看到。希望链接可以帮助你。好的,np,它确实做到了~