Browse Source

Trim when assigning to AuthToken

pull/1578/head
SubZero0 5 years ago
parent
commit
cc0e10e451
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      src/Discord.Net.Rest/DiscordRestApiClient.cs

+ 4
- 4
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -82,9 +82,9 @@ namespace Discord.API
{ {
return tokenType switch return tokenType switch
{ {
default(TokenType) => token?.TrimEnd(),
TokenType.Bot => $"Bot {token?.TrimEnd()}",
TokenType.Bearer => $"Bearer {token?.TrimEnd()}",
default(TokenType) => token,
TokenType.Bot => $"Bot {token}",
TokenType.Bearer => $"Bearer {token}",
_ => throw new ArgumentException(message: "Unknown OAuth token type.", paramName: nameof(tokenType)), _ => throw new ArgumentException(message: "Unknown OAuth token type.", paramName: nameof(tokenType)),
}; };
} }
@@ -129,7 +129,7 @@ namespace Discord.API
RestClient.SetCancelToken(_loginCancelToken.Token); RestClient.SetCancelToken(_loginCancelToken.Token);


AuthTokenType = tokenType; AuthTokenType = tokenType;
AuthToken = token;
AuthToken = token?.TrimEnd();
if (tokenType != TokenType.Webhook) if (tokenType != TokenType.Webhook)
RestClient.SetHeader("authorization", GetPrefixedToken(AuthTokenType, AuthToken)); RestClient.SetHeader("authorization", GetPrefixedToken(AuthTokenType, AuthToken));




Loading…
Cancel
Save