Django OAuth tool with multiple grants

I am using Django OAuth Toolkit and I would like to register applications with multiple grants. Some applications may only have one type of grant, others may have more.

Official documentation:

http://django-oauth-toolkit.readthedocs.io/en/latest/advanced_topics.html#multiple-grants

recommends:

class MyApplication(AbstractApplication):
def allows_grant_type(self, *grant_types):
    # Assume, for this example, that self.authorization_grant_type is set to self.GRANT_AUTHORIZATION_CODE
    return bool( set(self.authorization_grant_type, self.GRANT_CLIENT_CREDENTIALS) & grant_types )

      

but I get the error "TypeError: set expected at most 1 argument, got 2"

Also from my understanding this does not change the model in the db. This will return if the intersection of the sets is empty or not. Wouldn't this (if it works) GRANT_CLIENT_CREDENTIALS be available to all applications?

+3


source to share


1 answer


as the error says the set function expects one parameter you gave it 2 so you need to change the code a bit.



    return bool( set([self.authorization_grant_type, self.GRANT_CLIENT_CREDENTIALS]) & set(grant_types) )

      

+1


source







All Articles