在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):flavors/django-graphql-social-auth开源软件地址(OpenSource Url):https://github.com/flavors/django-graphql-social-auth开源编程语言(OpenSource Language):Python 97.0%开源软件介绍(OpenSource Introduction):Django GraphQL Social AuthPython Social Auth support for Django GraphQL Dependencies
InstallationInstall last stable version from Pypi. pip install django-graphql-social-auth See the documentation for further guidance on setting Python Social Auth. Add the import graphene
import graphql_social_auth
class Mutations(graphene.ObjectType):
social_auth = graphql_social_auth.SocialAuth.Field() Session authentication via accessToken.
mutation SocialAuth($provider: String!, $accessToken: String!) {
socialAuth(provider: $provider, accessToken: $accessToken) {
social {
uid
extraData
}
}
} JSON Web Token (JWT)Authentication solution based on JSON Web Token. Install additional requirements. pip install 'django-graphql-social-auth[jwt]' Add the import graphene
import graphql_social_auth
class Mutations(graphene.ObjectType):
social_auth = graphql_social_auth.SocialAuthJWT.Field() Authenticate via accessToken to obtain a JSON Web Token. mutation SocialAuth($provider: String!, $accessToken: String!) {
socialAuth(provider: $provider, accessToken: $accessToken) {
social {
uid
}
token
}
} RelayComplete support for Relay. import graphene
import graphql_social_auth
class Mutations(graphene.ObjectType):
social_auth = graphql_social_auth.relay.SocialAuth.Field()
Relay mutations only accepts one argument named input: mutation SocialAuth($provider: String!, $accessToken: String!) {
socialAuth(input:{provider: $provider, accessToken: $accessToken}) {
social {
uid
}
}
} CustomizingIf you want to customize the import graphene
import graphql_social_auth
class SocialAuth(graphql_social_auth.SocialAuthMutation):
user = graphene.Field(UserType)
@classmethod
def resolve(cls, root, info, social, **kwargs):
return cls(user=social.user) Authenticate via accessToken to obtain the user id. mutation SocialAuth($provider: String!, $accessToken: String!) {
socialAuth(provider: $provider, accessToken: $accessToken) {
social {
uid
}
user {
id
}
}
} Project templateThere is a Django project template to start a demo project. Gracias @omab / Python Social Auth. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论