No project description provided
Project description
django-graphql-google-accounts
fk django allauth is created 7 tables.
but we need only google accounts and we will only use graphql token authentication.
WARNING
Create a user table that uses only Google accounts.
Use is not recommended unless it is the initial setting.
Table Columns
column |
---|
uid |
nickname |
pitcure |
locale |
is_active |
is_admin |
updated_at |
created_at |
Installation
pip install django-graphql-google-accounts
Setup
configure base settings
add this app and settings
# settings.py
INSTALLED_APPS = [
# ...
'django.contrib.auth',
'django.contrib.sites',
'accounts',
]
# ...
ACCOUNTS_SETTINGS = {
# change secret example: https://djecrety.ir/
'token_secret': '^yb9tjg_hif0jym(d42j=vc#kyy=e_t#bjs)xy9y9)=tf&)!-2',
'claim': {
'iss': '', # 발급자
'sub': '', # 제목
'aud': '', # 대상
'exp': 1800, # accessToken expire time seconds
},
'refresh_token_expire': 30, # days / only verify check day
'google': {
'client_id': '<GOOGLE-CLIENT-ID>',
'secret': '<GOOGLE-SECRET>',
'redirect_uri': '/auth/google/callback',
'front_redirect_uri': 'http://localhost:8081/auth/google/callback',
}
}
AUTH_USER_MODEL = 'accounts.User'
configure urls
# urls.py
from django.urls import path, include
from accounts.views import GoogleLoginView, GoogleCallbackView
urlpatterns = [
# ...
path('login', GoogleLoginView.as_view()),
path('auth/google/callback', GoogleCallbackView.as_view()),
]
Refresh Token
Mutate
HTTP Headers
{
"Authorization": "Bearer <accessToken>"
}
Mutation
mutation {
refreshToken(token: "=0ujbayhl43l6m=vleqpa#&k(jaqlv0-p&qn7jl1#*nv@%v&=+") {
ok
accessToken
refreshToken
}
}
Login Required
verify accessToken timeout and uid
import graphene
# from example.types import ExampleType
from accounts.decorators.define import login_required
class ExampleQuery:
example = graphene.List(ExampleType)
@staticmethod
@login_required
def resolve_example():
return example.objects.all()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for django_graphql_google_accounts-0.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 095982ccdb59e68cf85f13a73ea1341871b00303394f635549d05f7c3aafcb3d |
|
MD5 | af8ec73a7edeb298ba484601ffa9fb92 |
|
BLAKE2b-256 | a74ad8268ec8ee564843e7d3141dd2a6bb968f23217946242cf6792a0599a4f2 |