Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't seem to handle "realm" properly. #50

Closed
jt55401 opened this issue May 17, 2017 · 9 comments
Closed

Doesn't seem to handle "realm" properly. #50

jt55401 opened this issue May 17, 2017 · 9 comments

Comments

@jt55401
Copy link

jt55401 commented May 17, 2017

The method we're calling requires the use of the Oauth realm, and we tried specifying that in the request_data.data map we sent do the oauth.authorize method. This "almost worked", but not quite.

Issues:

  1. The realm was included in the string to sign, but that should not be so.
  2. The realm was properly included in the OAuth header string, but it was last (per alphabetical order) but realm is required to be first in the header.

We worked around for now by NOT specifying the realm in the data, and instead, manually adding it before use...

var request_data = {    
    url: 'http://www.example.com',
    method: 'GET'
};

// generate the auth header WITHOUT any realm.
var headers = oauth.toHeader(oauth.authorize(request_data, token));
// manually add the realm after the fact:
headers.Authorization = headers.Authorization.replace("OAuth ", 'OAuth realm="12345",');

request({    
    url: request_data.url,
    method: request_data.method,
    headers: headers
}, function(error, response, body) {    
    console.log(body);
});
@ddo
Copy link
Owner

ddo commented Jun 7, 2017

working on it soon

@ddo
Copy link
Owner

ddo commented Jun 7, 2017

please checkout the newest code and test with your oauth service. the new options is realm, ex:

var oauth = new OAuth({
    consumer: {
        key: "batch-dbc2cd8c-6ca8-463b-96e2-6d8683eac6fd",
        secret: "4S4Rvm25CJZWv7HBg5HOhhlRTBSZ7npl"
    },
    realm: "https://ddo.me/",
    signature_method: 'HMAC-SHA1',
    hash_function: hash_function_SHA1
});

i will public on npm after your tests. ty

@jt55401
Copy link
Author

jt55401 commented Jun 7, 2017

Will do later today, thanks!

@RobGriggs
Copy link

Hi there @ddo,

I've been working @jt55401. He figured out the workaround when I was unable implement the library using a realm. I pulled the latest code into the my project and reconfigured my connection script to follow the format that you outlined above.

Connection was successful using the new realm option!

capture

Thanks all.

@ddo
Copy link
Owner

ddo commented Jun 7, 2017

does your realm contain any non alphabet characters such as /, :

@jt55401
Copy link
Author

jt55401 commented Jun 7, 2017

in our case, no.

@ddo
Copy link
Owner

ddo commented Jun 8, 2017

so everything ok?

@jt55401
Copy link
Author

jt55401 commented Jun 9, 2017

Yes, works great now!

@ddo
Copy link
Owner

ddo commented Jun 9, 2017

@ddo ddo closed this as completed Jun 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants