使用NestJS获取承载令牌

时间:2019-02-06 15:35:24

标签: nestjs simple-oauth2

我正在使用simple-oauth2来获取令牌。

我正在遵循文档中的示例:

try {
  const credentials: ModuleOptions = {
    client: {
      id: 'myClientId',
      secret: 'mysecret',
    },
    auth: {
      tokenHost: 'https://mysts/connect/token',
    },
    options: {
      authorizationMethod: 'header',
      bodyFormat: 'json',
    },
  };

  const tokenConfig = {
    code: 'access_token',
    redirect_uri: 'http://localhost:3000/callback',
    scope: ['email.send', 'c3.full', 'org.full'],
  };

  const oauth2 = oauthLib.create(credentials);
  const result = await oauth2.authorizationCode.getToken(tokenConfig);
  const accessToken = oauth2.accessToken.create(result);

问题在于后端需要承载令牌,而accessToken的类型为AccessToken

如何获取我的不记名令牌?

非常感谢。

0 个答案:

没有答案
相关问题