On Wed, Aug 14, 2013 at 6:26 PM, Yuri Prezument <
y.pre...@gmail.com> wrote:
> It's getting too complicated... I don't really know what to do about it.
> Maybe I should try using django-oauth-toolkit instead of oauth2-provider.
>
Provided that as per RFC 6749 a Token endpoint of an OAuth2 provider
accepts data in "application/x-www-form-urlencoded" format, Django
OAuth Toolkit is flexible enough to let you bend the standard a little
bit :-), even if the procedure is not trival nor documented.
If you follow the path of a token request from the view backward, the
story is this: TokenView handles the request and in the post method
makes a call to create_token_response:
https://github.com/evonove/django-oauth-toolkit/blob/master/oauth2_provider/views/base.py#L136
create_token_response is provided by OAuthLibMixin:
https://github.com/evonove/django-oauth-toolkit/blob/master/oauth2_provider/views/mixins.py#L95
DOT has the concept of "oauth providers", to which delegates oauth
logic. OAuthLibMixin uses "oauthlib provider", the default, retrieved
by the method get_oauthlib_core which returns an instance of
OAuthLibCore:
https://github.com/evonove/django-oauth-toolkit/blob/master/oauth2_provider/views/mixins.py#L66
Then the part most interesting for you. The _extract_params method
from OAuthLibCore takes a Django request, extracts the data from it
and put such data back in the OAuth2 workflow. This is the place where
DOT assumes data is in "application/x-www-form-urlencoded" format, and
where you can implement your own logic, likely taking data from
request.body instead of request.POST:
https://github.com/evonove/django-oauth-toolkit/blob/master/oauth2_provider/backends.py#L18
So this is what you have to do (not tested, take it as an hint):
* Implement your own oauthlib provider, you can derive from
OAuthLibCore and override just the _extract_params method.
* Implement your own oauth mixin, you can derive from OAuthLibMixin
and make it use the provider from previous step
* Implement your own TokenView, using the mixi from previous step.
Hope this helps and I didn't go too much OT for this list.
Should you have any further question regarding Django OAuth Toolkit,
feel free to ask in the official mailing list:
http://groups.google.com/group/django-oauth-toolkit
and if you step into some bug or design flaw, please report an issue,
any help is appreciated!
Cheers
--
M.
http://twitter.com/maxpippi ::
http://masci.wordpress.com