11from django .shortcuts import render
22from django .http import HttpResponse
3+ from .models import Auth
34import requests
45import datetime
56
@@ -24,8 +25,11 @@ def auth(request):
2425 code = request .GET .get ('code' )
2526 context = request .GET .get ('context' )
2627 scope = request .GET .get ('scope' )
28+ 29+ # redirect = 'https://dd6100868f41.ngrok.io/auth'
2730 redirect = config ('callBackURL' )
2831
32+ 2933 store_hash = context .split ('/' )[1 ]
3034
3135 client = BigcommerceApi (client_id = client_id (), store_hash = config ('apiStoreHash' ))
@@ -34,12 +38,14 @@ def auth(request):
3438 bc_user_id = token ['user' ]['id' ]
3539 email = token ['user' ]['email' ]
3640 access_token = token ['access_token' ]
37- pp = request .build_absolute_uri ()
38- print ('this is url ' + pp )
39- # b = Auth.objects.create(user_id = bc_user_id ,mail = email, storehash = store_hash, token = access_token)
4041
41- return render (request , 'auth.html' )
42+ a , created = Auth .objects .get_or_create (storehash = store_hash )
43+ a .user_id = bc_user_id
44+ a .mail = email
45+ a .storehash = store_hash
46+ a .token = access_token
47+ a .save ()
4248
43- return HttpResponse ( "Something Went Wrong" )
49+ return render ( request , 'index.html' )
4450
45- 51+ return HttpResponse ( "Something Went Wrong" )
0 commit comments