You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was getting signature failures when a query parameter had a properly escaped space. I replaced the existing escape method with url.QueryEscape and fixed. Patch below.
diff --git a/oauth.go b/oauth.go
index d8e0ea2..07cccac 100644
--- a/oauth.go
+++ b/oauth.go
@@ -957,23 +957,7 @@ func (s *RSASigner) SignatureMethod() string {
}
func escape(s string) string {
- t := make([]byte, 0, 3*len(s))
- for i := 0; i < len(s); i++ {
- c := s[i]
- if isEscapable(c) {
- t = append(t, '%')
- t = append(t, "0123456789ABCDEF"[c>>4])
- t = append(t, "0123456789ABCDEF"[c&15])
- } else {
- t = append(t, s[i])
- }
- }
- return string(t)
-}
-
-func isEscapable(b byte) bool {
- return !('A' <= b && b <= 'Z' || 'a' <= b && b <= 'z' || '0' <= b && b <= '9' || b == '-' || b == '.' || b == '_' || b == '~')
-
+ return url.QueryEscape(s)
}
The text was updated successfully, but these errors were encountered:
According to this https://dev.twitter.com/oauth/overview/creating-signatures, space should be encoded into %20, not + character. So the oauth package does this correctly. Who is telling you your signatures are wrong? Maybe they implemented this incorrectly.
I was getting signature failures when a query parameter had a properly escaped space. I replaced the existing
escape
method with url.QueryEscape and fixed. Patch below.The text was updated successfully, but these errors were encountered: