Issue #10239 open

Get pr diff using oauth1 API returns 401 (BB-11086)

Roland Poulter
created an issue

I'm trying to get the diff of a pull request using one of the links that is returned from: https://bitbucket.org/api/2.0/repositories/USER/REPO/pullrequests/ID

Which returns a link for getting a diff for the pull request:

https://bitbucket.org/api/2.0/repositories/USER/REPO/pullrequests/ID/diff

But when I make this request with oauth authentication it returns a 401 status code? This url works fine when I use by bitbucket session from a browser, but not with oauth.

Thanks!

Comments (9)

  1. Erik van Zijst staff

    This is the result of a bug in OAuth's URL escaping logic that mistreats some characters.

    Nerdy explanation: The /diff URL returns a redirect to a URL compare view url that contains a colon, which in turn triggers a URL escaping inconsistency on the OAuth signature base string generation.

    A fix is underway and I'll update this ticket accordingly.

  2. Roland Poulter reporter

    I tried this using the restbrowser.bitbucket.org app and using the oauth npm module. However I don't think this was the issue I was having. I was getting a 401 unauthorized status code, but only when I tried to get the diff, simply getting the PR worked fine in both cases. You seem to be right though about my library not supporting redirects:

    https://github.com/ciaranj/node-oauth/issues/201

    But it didn't get that far in both cases. Unless the route was returning a 401 status code when it should have returned a 3xx code.

  3. Roland Poulter reporter

    Do you know if the restbrowser.bitbucket.org app has this bug or not? I can look into whether the npm oauth module has this problem or not. Thanks for pointing this out to me.

  4. Log in to comment