Reputation: 941
I'm using oauth2_provider
+ rest_framework
. I have configured several client applications, and they successfully authenticate and receive access tokens.
I would like to have the client app in the request (Eg. request.client
). Perhaps I should create some kind of middleware, which sets it, but I'm not sure what is the proper way to do it. Or maybe this functionality is already provided by the oauth2_provider
/oauthlib
, and I have overlooked it?
The client should be set when:
Python v3.5.3, Django v1.10.6
Upvotes: 1
Views: 992
Reputation: 148
oauth2_provider AccessToken
has a foreign key
to the application issued that token
You can get the application form the access token like this: application = request.auth.application
Upvotes: 3
Reputation: 515
AbstractApplication
class has foreign key to settings.AUTH_USER_MODEL
https://github.com/evonove/django-oauth-toolkit/blob/0.12.0/oauth2_provider/models.py#L62
So if you are using default Application
class you could get the clients by request.user.oauth2_providers_applications
Upvotes: 0