Skip to content

Commit

Permalink
Form- (not json-) encode auth-params when POSTing to authUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonWoolf committed Dec 3, 2015
1 parent e2e8e5e commit f3c6562
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion common/lib/client/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,16 @@ var Auth = (function() {
};
Logger.logAction(Logger.LOG_MICRO, 'Auth.requestToken().tokenRequestCallback', 'Sending; ' + authOptions.authUrl + '; Params: ' + JSON.stringify(authParams));
if(authOptions.authMethod && authOptions.authMethod.toLowerCase() === 'post') {
Http.postUri(rest, authOptions.authUrl, authHeaders || {}, authParams, {}, authUrlRequestCallback);
var headers = authHeaders || {};
if(typeof(authParams) === 'object') {

This comment has been minimized.

Copy link
@paddybyers

paddybyers Dec 3, 2015

Member

Since authParams here is the result of Utils.mixin(), why would it be anything other than an object?

This comment has been minimized.

Copy link
@SimonWoolf

SimonWoolf Dec 3, 2015

Author Member

..Good point. I was picturing it as coming straight from authOptions. 😣

/* send body form-encoded */
headers['content-type'] = "application/x-www-form-urlencoded";

This comment has been minimized.

Copy link
@paddybyers

paddybyers Dec 3, 2015

Member

Single quotes please (and line below)

body = Utils.toQueryString(authParams).slice(1); /* slice is to remove the initial '?' */
} else {
headers['content-type'] = "text/plain";
body = authParams;
}
Http.postUri(rest, authOptions.authUrl, headers, body, {}, authUrlRequestCallback);
} else {
Http.getUri(rest, authOptions.authUrl, authHeaders || {}, authParams, authUrlRequestCallback);
}
Expand Down

1 comment on commit f3c6562

@SimonWoolf
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.