Browse Source

Trim whitespace from tokens before logging in

This change trims whitespace characters from the supplied token before it is used to log in. Users can encounter this accidentally if they read their token from a file that ends with a blank line.

Leading whitespace will make the token invalid. Trailing whitespace or \n (not \r\n) will also fail to log in. \r\n (CRLF) doesn't fail because of the line break style for http request headers.
pull/1305/head
Chris Johnston 6 years ago
parent
commit
b091529548
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      src/Discord.Net.Rest/DiscordRestApiClient.cs

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

@@ -128,7 +128,7 @@ namespace Discord.API
RestClient.SetCancelToken(_loginCancelToken.Token); RestClient.SetCancelToken(_loginCancelToken.Token);


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




Loading…
Cancel
Save