URI query not in alphabetical order in Ruby
Hi I have here a method that pass URL into redirect_url local variable
I'm trying to achieve a URL like this:
https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=IDHERE&redirect_uri=https%3A%2F%2Fwww.mysite.com%2Fcode_callback.jsp&state=mystate
But using my code the response_type query goes to the end of the URL.
Making it something like this:
https://login.salesforce.com/services/oauth2/authorize?client_id=IDHERE&redirect_uri=https%3A%2F%2Fwww.mysite.com%2Fcode_callback.jsp&state=mystate&response_type=code
Here's my code:
def authorize_url
request_url = URI::HTTPS.build({
host: "login.salesforce.com",
path: "/services/oauth2/authorize",
query: {
response_type: 'code',
client_id: client_id,
redirect_uri: callback_url
}.to_param
}).to_s.gsub('.plus.', '+').html_safe
end
No comments:
Post a Comment