-
-
Notifications
You must be signed in to change notification settings - Fork 486
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
The authorization endpoint now returns a 200 on "oob" oauth_callbacks. #199
Conversation
@squirly Thanks for the PR :) and sorry for the late response. Before I dig into code review I think this PR warrants some discussion because it attempts to add detail to a rather vague area of the OAuth 1 spec, handling out of bound "oob" callbacks. The definition of
Note: The If the callback URI has been established through other means (i.e. client registration) then a reasonable approach would be that the provider replaces "oob" during If the client is unable to receive callbacks (CLI app for example) then the provider could replace "oob" to redirect the client to a view returning the verifier in the response body instead of the URI. This would require some extra work on the provider or alternatively this PR. However since this is not per the spec and might not be of interest to all providers I'm inclined to let each provider implement this if they want it.
|
It seems that the current response suggests that a 302 Found (Redirect) response should be returned to the user-end in all cases. Even on a "oob" callback. It would be more appropriate to return no status code on a "oob" callback from this library, as this is truly making no assumptions. As we are talking about the authorization endpoint, and how it relates to the OAuth RFC. It seems that having location returned as the first parameter is not the most straight forward API, because it convolutes the request and access token endpoints APIs. An HTTP response like object is returned by the library for all endpoints. A 302 response should have a field "Location uri", 10.3.3 302 Found. Adding the URI to the header would be more intuitive, as it follows http, than having it returned as the first parameter. Though, this is not actually in the OAuth RFC as there is not obligation for the provider to return a 302 response to the client.
2.2 Resource Owner Authorization In my opinion, regardless of the OAuth RFC, I think that a 302 response is a very acceptable assumption if a callback is provided. But if this assumption is made, the URI should be moved into the headers return parameter and the URI return parameter be removed completely. I am willing to make a pull request for these changes, but I would like to further discuss before doing any coding. |
Excellent point about the Location header, that is indeed better. While oauthlib is still not stable such a change might break compatibility with existing implementations. Roping in @synasius and @lepture for input on this. If it makes sense an alternative would be to add the Location header but keep the returned URI as is. This could be confusing tho. I'm still not sure why the redirect uri would remain plain "oob" after request token creation. While I agree that returning a 200 with the token is more useful than an invalid redirect uri I am not sure I see which use cases this would be for. Got any example to help enlighten me? |
The API change went out to pypi 23 days ago (0.5.0 July 9, 2013). So if there is another API change sooner would be better than later. |
EXAMPLE
With the proposed API:
The proposed API allows for more generic handling, |
It makes sense to me, and Flask-OAuthlib is compatible with this issue now. |
There still is not a clear use case here where my previous suggestion does not apply. In your example you are really just presenting an alternate view if the callback was "oob" originally and never updated. If the user is able to follow a redirect why not just populate the redirect uri during the request token creation? It will result in one more request, is that your concern?
If the extra request is the concern I could see a point. We could definitely provide this return as a fallback if the oob was not set, and/or add a The only other use case I see now with returning 200 here is if the client is unable to follow a redirect and try to automate their way through the authorization step. However AFAIK most python http libraries can follow redirects. If you are driving a user-agent like webkit I see even less issue following a redirect. |
I would like to have less requests. I find that eliminating requests wherever possible can lead to easier to follow code. Also, changing the redirect URL in a function called I feel that in order to be clearer to the implementor, on an oob callback the library provides some indication that the server is responsible for displaying the verifier. This is not 100% clear by returning a redirect. What I am getting at is that my use case for oob is fairly widespread across oauth implementations. |
I see there is a |
@squirly While I think most providers want to implement their own view for presenting the verifier I think falling back to this urlencoded response is a good idea. Thanks for taking all this time to convince me and being so thorough in the code updates :) Re-using I quite like removing the returned URI which mostly have been None and useless anyway. I think we should do this to all OAuth 2 endpoints as well and when that is done maybe release 0.6 rather than 0.5 since it changes the API quite a bit and users might be surprised if a small update breaks everything. Feel free to dig into this in a new PR if you'd like, if not I'll try and get around to it. @squirly Last thing. Please change |
@squirly Awesome work. Looking forward to more of it ;) |
The authorization endpoint now returns a 200 on "oob" oauth_callbacks.
It does not make sense to return a
302
withoob?oauth_token=...&oauth_verifier=...
.Instead the endpoint should return a
200
with the data in the body. The implementer is responsible for presenting this data to the client. This also keeps the endpoint API consistent.