我在LinkedIn上写了一个oAuth2进程,在获得身份验证令牌后,如果我发出请求,我会得到以下回复:
然后,用户已撤消此请求中使用的令牌。
但是,如果我这样做:
await new Promise(resolve => setTimeout(resolve, 5000))
然后发出请求,它工作得很好。 如果我记录请求的URL,然后手动尝试,仍然有效。
令牌的有效期为2个月。
如何在验证后直接发出请求,而不是等待5秒? (试过3秒,没用)
这是使用simple-oauth2
的广泛代码:
const result = await this.client.authorizationCode.getToken({
code: req.query.code,
redirect_uri: this.redirect_uri
});
console.log('Result', result);
const accessToken = this.client.accessToken.create(result);
console.log({ accessToken: accessToken.token.access_token });
await wait(5000);
const profile = await this.profile(accessToken.token.access_token);