我尝试在Discord中使用oauth approach of adding webhooks频道。工作流程是用户使用OAuth对我的应用程序进行身份验证。然后我将它们重定向到:
ApiClient::API_URL.'/oauth2/authorize?client_id='.Discord::appKey().'&scope=webhook.incoming&redirect_uri='.urlencode($webhookCallback->callbackUrl()).'&response_type=code');
重定向网址有效,因为它允许OAuth用户选择服务器/频道。
当您交换访问令牌的授权码时,令牌响应将包含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')
],
]);
我从API获得的响应是:
Client error: `POST https://discordapp.com/api/oauth2/token` resulted in a `401 UNAUTHORIZED` response:
{"error": "access_denied"}
完成此请求需要哪种授权类型?
答案 0 :(得分:4)
'grant_type' => 'client_credentials',
需要
USE [KevinMayhewLive]
GO
/****** Object: StoredProcedure [dbo].[toFileSalesData] Script Date: 06/19/2017 13:36:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[toFileSalesData]
as
--xp_cmdshell will shell out to the command line to run bcp
--the user account that runs this procedure should have file access to create and write files
--bcp does not append to files, all data will be overwritten each time this procedure runs
EXEC KevinMayhewLive..xp_cmdshell 'bcp "SELECT * FROM KevinMayhewLive.dbo.KM_CUSTOMER_DATA" queryout \\SERVER3\Docs\Emarsys_Sync\Customer_data\CUSTOMER_DATA.csv -c -t, -T -S'
EXEC KevinMayhewLive..xp_cmdshell 'bcp "SELECT * FROM KevinMayhewLive.dbo.KM_SALES_DATA" queryout \\SERVER3\Docs\Emarsys_Sync\Sales_Data\sales_items.csv -c -t, -T -S'