【发布时间】:2020-12-15 15:23:01
【问题描述】:
当我在浏览器中使用自己的 client_id 访问以下 URL 时:
我需要登录,然后我被重定向到: http://localhost:8888/auth#access_token=myAccessToken&expires_in=28800&token_type=bearer&state=a39fh23hnf23
现在我有一个 node.js 应用程序,我想在其中使用我的访问令牌进行 API 调用,直到现在我每次都手动执行上述操作来获取我的访问令牌,当然,这不是最佳的。因此,我的问题是:如何在不使用浏览器的情况下获取访问令牌?
现在我有以下内容
sendRequestAccessToken(): Promise<any> {
const scope = 'signature';
const clientId = '*my client id*';
const state = 'a39fh23hnf23';
const url = `https://account-d.docusign.com/oauth/auth?
response_type=token
&scope=${scope}
&client_id=${clientId}
&state=${state}
&redirect_uri=http://localhost:8888/auth
`;
return this.httpService.get(url).toPromise(); }
此函数的响应包含大量数据,但没有访问令牌。
【问题讨论】:
-
授权代码授权工作流每次都需要用户/浏览器交互。如果您希望能够以编程方式生成令牌,则应查看 JWT / Impersonation auth,它只需要用户交互一次即可获得同意。
标签: docusignapi