【发布时间】:2023-02-08 01:21:55
【问题描述】:
我已经实现了新的 Google Identity Services 来获取 access_token 来调用 Youtube API。 我尝试在 Angular 应用程序上使用它。
this.tokenClient = google.accounts.oauth2.initTokenClient({
client_id: googleApiClientId,
scope: 'https://www.googleapis.com/auth/youtube.readonly',
callback: (tokenResponse) => {
this.accessToken = tokenResponse.access_token;
},
});
当我调用 this.tokenClient.requestAccessToken() 时,我可以获得一个访问令牌并使用 Youtube API,这是可行的。
但一个小时以后,此令牌过期。我有这个错误:"Request had invalid authentication credentials."
如何为用户透明地获取新刷新的 access_token ?
【问题讨论】:
标签: api authentication oauth-2.0 authorization access-token