Comments (3)
Andrew. jsOAuth already handles the encoding and decoding of urls for you. What you're prob experiencing is double encoding.
—
Sent from Mailbox for iPhone
On Fri, Mar 15, 2013 at 7:46 PM, Andrew Trusty [email protected]
wrote:
I was calling an OAuth REST API endpoint with a url that contained a GET parameter with spaces in it. The url encoder I was using encoded the spaces as plus symbols (+). When I passed the encoded url (eg. https://domain.com/docs?query=foo+bar ) to the getJSON method it decoded it in an unexpected way such that the plus symbol was left in place instead of being decoded to a space. Then, when the url was re-encoded before being request was made, the plus symbol was encoded as %2B which caused the server to think the character was a plus symbol instead of a space as was originally intended.
My solution to this was to use a different encoder that encoded spaces as %20 instead of plus symbols before passing the url to the OAuth library but I was wondering if this was intended behavior or accidental on the part of the OAuth library.
TL;DR
What happened:
OAuth.urlDecode('a+b') === 'a+b'
What I expected:OAuth.urlDecode('a+b') === 'a b'
Reply to this email directly or view it on GitHub:
#45
from jsoauth.
It does look like the encoding is automatically handled if I use the request method and use the data option but I don't see a way to pass the GET parameters as an object when using either the get or getJSON convenience methods..
from jsoauth.
You'll have to use request and handle the json parsing yourself. Its fairly simple JSON.parse(data); in your success callback
—
Sent from Mailbox for iPhone
On Fri, Mar 15, 2013 at 7:57 PM, Andrew Trusty [email protected]
wrote:
It does look like the encoding is automatically handled if I use the request method and use the data option but I don't see a way to pass the GET parameters as an object when using either the get or getJSON convenience methods..
Reply to this email directly or view it on GitHub:
#45 (comment)
from jsoauth.
Related Issues (20)
- OAuth 2.0 Support HOT 11
- postJSON - Content-Type: 'application/json' HOT 4
- Support streaming responses HOT 11
- No request token error HOT 7
- jsOAuth and LinkedIn HOT 3
- Using requirejs breaks jsOAuth HOT 3
- encodable query params are double percent encoded HOT 2
- QueryString.setQueryParams doesn't decode query values HOT 3
- 1.3.6 error HOT 1
- Uncaught ReferenceError: netscape is not defined HOT 3
- Making life simpler: Chrome iOS-Simulator App HOT 1
- Error auth Appelerator sdk version >=2
- Missing onerror callback for Titanium HTTPClient
- urlEncode method does not encode the tab character
- jsOAuth - Backbone.js HOT 4
- Make package installable using bower HOT 3
- It's not possible to make GET requests with two query parameters having the same name HOT 3
- Twitter 401 Unauthorized for get/post methods after access_token is saved HOT 6
- phonegap error, netscape is not defined HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsoauth.