我正在使用Django OAuth Toolkit,我想注册多个授权的应用程序。有些应用程序可能只有一种类型的授权,其他应用程序可能有更多。
官方文件:
http://django-oauth-toolkit.readthedocs.io/en/latest/advanced_topics.html#multiple-grants
建议:
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 )
但我得到一个错误,说“TypeError:设置最多1个参数,得到2”
另据我的理解,这不会修改数据库中的模型。如果集合的交集是空的,则返回。那么这不会使所有应用程序可用的GRANT_CLIENT_CREDENTIAL(如果有效)吗?
答案 0 :(得分:1)
return bool( set([self.authorization_grant_type, self.GRANT_CLIENT_CREDENTIALS]) & set(grant_types) )