oauth2 icon indicating copy to clipboard operation
oauth2 copied to clipboard

Don't use `url.QueryEscape` for clientID and clientSecret

Open dmgcodevil opened this issue 4 years ago • 3 comments

I have '!' symbol in my clientSecret, using escape function produces a value that rejected by oauth server.

Creds:

clientID := "test"
clientSecret := "t!st"

Accepted:

	if authStyle == AuthStyleInHeader {
		req.SetBasicAuth(clientID, clientSecret)
	}

Rejected:

	if authStyle == AuthStyleInHeader {
		req.SetBasicAuth(url.QueryEscape(clientID), url.QueryEscape(clientSecret))
	}

Since it's a header value, not query, is it possible to remove: QueryEscape ?

dmgcodevil avatar Mar 23 '20 21:03 dmgcodevil

I have the same issue. Escaping username and password is unnecessary (because the value of the header will be base64 encoded anyhow), and wrong accoring to the basic auth rfc: https://tools.ietf.org/html/rfc2617#section-2

holgpar avatar May 13 '20 11:05 holgpar

It seems like this is already a year old issue, but would like to note that url.QueryEscape is necessary to adhere to the oauth 2.0 spec: https://tools.ietf.org/html/rfc6749#section-2.3.1

xorkevin avatar Feb 06 '21 22:02 xorkevin

@xorkevin, yes, it's a must.

adeinega avatar May 12 '21 23:05 adeinega

@seankhliao what if the provider doesn't respect this OAuth 2.0 spec like [Epic Games EOS OAuth 2.0] (https://dev.epicgames.com/docs/web-api-ref/connect-web-api)? They don't accept to receive url encoded data, so I can't make EOS OAuth 2.0 work because of these url.QueryEscape. Perhaps we can add a default bool true in the Endpoint struct to allow the switch not to use url.QueryEscape for special cases like this?

Jorgagu avatar Nov 13 '23 11:11 Jorgagu