Added RpcToken param
This commit is contained in:
@@ -148,13 +148,15 @@ namespace Discord.API
|
||||
_webSocketClient.SetCancelToken(_connectCancelToken.Token);
|
||||
|
||||
bool success = false;
|
||||
for (int port = DiscordRpcConfig.PortRangeStart; port <= DiscordRpcConfig.PortRangeEnd; port++)
|
||||
int port;
|
||||
string uuid = Guid.NewGuid().ToString();
|
||||
|
||||
for ( port = DiscordRpcConfig.PortRangeStart; port <= DiscordRpcConfig.PortRangeEnd; port++)
|
||||
{
|
||||
try
|
||||
{
|
||||
string url = $"wss://discordapp.io:{port}/?v={DiscordRpcConfig.RpcAPIVersion}&client_id={_clientId}";
|
||||
string url = $"wss://{uuid}.discordapp.io:{port}/?v={DiscordRpcConfig.RpcAPIVersion}&client_id={_clientId}";
|
||||
await _webSocketClient.ConnectAsync(url).ConfigureAwait(false);
|
||||
SetBaseUrl($"https://discordapp.io:{port}/");
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
@@ -162,9 +164,11 @@ namespace Discord.API
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (!success)
|
||||
throw new Exception("Unable to connect to the RPC server.");
|
||||
|
||||
SetBaseUrl($"https://{uuid}.discordapp.io:{port}/");
|
||||
ConnectionState = ConnectionState.Connected;
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -238,12 +242,13 @@ namespace Discord.API
|
||||
};
|
||||
return await SendRpcAsync<AuthenticateResponse>("AUTHENTICATE", msg, options: options).ConfigureAwait(false);
|
||||
}
|
||||
public async Task<AuthorizeResponse> SendAuthorizeAsync(string[] scopes, RequestOptions options = null)
|
||||
public async Task<AuthorizeResponse> SendAuthorizeAsync(string[] scopes, string rpcToken = null, RequestOptions options = null)
|
||||
{
|
||||
var msg = new AuthorizeParams()
|
||||
{
|
||||
ClientId = _clientId,
|
||||
Scopes = scopes
|
||||
Scopes = scopes,
|
||||
RpcToken = rpcToken != null ? rpcToken : Optional.Create<string>()
|
||||
};
|
||||
if (options == null)
|
||||
options = new RequestOptions();
|
||||
|
||||
@@ -8,5 +8,7 @@ namespace Discord.API.Rpc
|
||||
public string ClientId { get; set; }
|
||||
[JsonProperty("scopes")]
|
||||
public string[] Scopes { get; set; }
|
||||
[JsonProperty("rpc_token")]
|
||||
public Optional<string> RpcToken { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user