按照 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
我是 React Native 的新手,我遇到了一个我自己无法解决的问题。
到目前为止,这是我使用它的方式:
export default class Form extends React.Component {
state = {index: 0};
_keyExtractor = (item, index) => item.id;
myscrollToIndex = () => {
this.setState({index: ++this.state.index});
this.flatListRef.scrollToIndex({animated: true,index: this.state.index});
};
_renderItem = ({item}) => (
<View>
<Question {...item} />
<Button label='Next' onPress={this.myscrollToIndex} style={styles.buttonNext}/>
</View>
)
render() {
return (
<View style={styles.container}>
<FlatList
horizontal={false}
ref={(ref) => { this.flatListRef = ref; }}
scrollEnabled
data={this.props.form}
extraData={this.state}
keyExtractor={this._keyExtractor}
renderItem={this._renderItem} />
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
我想将索引传递给 myscrolltoindex 函数,但我没有做到,因为当我这样做时 this.flatListRef 被排除了。
有没有人遇到过类似的问题?
感谢您的时间