Webhook OAuth - 如何为访问令牌交换webhook授权代码?

Web*_*net 5 discord

我正在尝试使用oauth方法将dischooks添加到Discord中的频道.工作流程是用户使用OAuth对我的应用程序进行身份验证.然后我将它们重定向到:

ApiClient::API_URL.'/oauth2/authorize?client_id='.Discord::appKey().'&scope=webhook.incoming&redirect_uri='.urlencode($webhookCallback->callbackUrl()).'&response_type=code');
Run Code Online (Sandbox Code Playgroud)

重定向网址有效,因为它允许OAuth'd用户选择服务器/频道.

当您交换访问令牌的授权代码时,令牌响应将包含webhook对象:

我正在使用以下请求尝试将授权代码转换为访问令牌而没有运气:

    $client = new Client();
    $response = $client->post('https://discordapp.com/api/oauth2/token', [
        'headers' => [
            'Accept' => 'application/json'
        ],
        'form_params' => [
            'grant_type' => 'authorization_code',
            'client_id' => env('DISCORD_APP_KEY'),
            'client_secret' => env('DISCORD_APP_SECRET'),
            'redirect_uri' => url('/discord/webhook-authorized'),
            'code' => $request->get('code')
        ],
    ]);
Run Code Online (Sandbox Code Playgroud)

我从API获得的响应是​​:

Client error: `POST https://discordapp.com/api/oauth2/token` resulted in a `401 UNAUTHORIZED` response:
{"error": "access_denied"}
Run Code Online (Sandbox Code Playgroud)

完成此请求需要哪种授权类型?

Web*_*net 4

'grant_type' => 'authorization_code',

需要是

'grant_type' => 'client_credentials',