Google 工作表 API 使用 React Native
Google Sheets API with React Native
react-native 的新手。尝试对位于 google 驱动器中的 google 电子表格进行简单的 crud 操作。我已经成功地为 react/node.js 实现了 react-native-google-signin and react-native-google-drive-api-wrapper and can see my spreadsheets. Next step is finding a react-native package that implements google sheets API v4. I've tried Iwark's/react-native-spreadsheet 的包,但是当尝试在 react-native 环境中构建时它会产生错误。任何方向将不胜感激。
我希望可以使用 googleapis and google-auth-library
两个库来做到这一点;
然后通过
初始化 api
var authClient = new googleAuth();
var auth = new authClient.OAuth2();
auth.credentials = {
access_token: accessToken
};
this.service = google.sheets({version: 'v4', auth: auth});
然后使用this.service
如果这没有多大意义,请等待几个小时或明天,我会帮助您制作一份工作副本。 :)
编辑:
这是我认为你应该做的,"
- 如果您有电子表格 public,请关注
- 如果您的电子表格是私有的
a) 您需要让用户登录(使用 firebase google 登录),然后获取 access_token 并在 https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}
中使用 access_token 或post 请求等
b) 在您处理所有这些的节点服务器中发出 post 请求
注意:本周末我可能会帮助您提供一个工作示例。
安装
npm install tabletop
进口
import Tabletop from 'tabletop';
使用
Tabletop.init({
key: url,
callback: googleData => {
console.log(googleData);
},
simpleSheet: true
})
正在发布您的 Google Sheet
url = File->Publish to the web then click Start publishing
react-native 的新手。尝试对位于 google 驱动器中的 google 电子表格进行简单的 crud 操作。我已经成功地为 react/node.js 实现了 react-native-google-signin and react-native-google-drive-api-wrapper and can see my spreadsheets. Next step is finding a react-native package that implements google sheets API v4. I've tried Iwark's/react-native-spreadsheet 的包,但是当尝试在 react-native 环境中构建时它会产生错误。任何方向将不胜感激。
我希望可以使用 googleapis and google-auth-library
两个库来做到这一点;
然后通过
var authClient = new googleAuth();
var auth = new authClient.OAuth2();
auth.credentials = {
access_token: accessToken
};
this.service = google.sheets({version: 'v4', auth: auth});
然后使用this.service
如果这没有多大意义,请等待几个小时或明天,我会帮助您制作一份工作副本。 :)
编辑: 这是我认为你应该做的,"
- 如果您有电子表格 public,请关注
- 如果您的电子表格是私有的
a) 您需要让用户登录(使用 firebase google 登录),然后获取 access_token 并在 https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}
中使用 access_token 或post 请求等
b) 在您处理所有这些的节点服务器中发出 post 请求
注意:本周末我可能会帮助您提供一个工作示例。
安装
npm install tabletop
进口
import Tabletop from 'tabletop';
使用
Tabletop.init({
key: url,
callback: googleData => {
console.log(googleData);
},
simpleSheet: true
})
正在发布您的 Google Sheet
url = File->Publish to the web then click Start publishing