首页 > 解决方案 > 如何在不使用浏览器的情况下获取访问令牌

问题描述

当我使用自己的 client_id 在浏览器中访问以下 URL 时:

https://account-d.docusign.com/oauth/auth?response_type=token&scope=signature&client_id=6d1a8594-xxxx-xxxx-xxxx-878e593de049&state=a39fh23hnf23&redirect_uri=http://localhost:8888/auth

我需要登录,然后我被重定向到: 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(); }

此函数的响应包含大量数据,但没有访问令牌。

标签: docusignapi

解决方案


请查看我们在此处提供的 SDK 示例:https ://github.com/docusign/code-examples-node

在这些示例中,我们提供了有关如何使用 api 使用令牌的示例。


推荐阅读