Nuxt.js 为访问令牌 Oauth2 交换授权码

时间:2021-05-16 16:02:55

标签: oauth-2.0 nuxt.js

我正在尝试将我在文档 the first step 中获得的授权代码交换为访问令牌。我遇到的问题是如何发送对令牌的请求,其中包含我刚刚在第一个请求中获得的代码。 这是我的代码:

auth: {
  redirect: {
    login: '/',
    callback: '/auth'
  },
  strategies: {
    wrike: {
      scheme: 'oauth2',
      endpoints: {
        authorization: 'https://login.wrike.com/oauth2/authorize/v4',
        token: 'https://login.wrike.com/oauth2/token',
        logout: '/'
      },
      token: {
        property: 'access_token',
        type: 'Bearer',
        maxAge: 1800
      },
      responseType: 'code',
      grantType: 'authorization_code',
      accessType: 'offline',
      clientId: XXXX,
      client_secret: YYYY
    }
  }
}

我不知道应该如何在客户端或服务器端设置重定向 URI?我应该如何做第二个请求? (下面这个)

POST https://login.wrike.com/oauth2/token
  //Parameters:
  client_id=<client_id>
  client_secret=<client_secret>
  grant_type=authorization_code
  code=<authorization_code>

0 个答案:

没有答案