Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions OAuth2DjangoSampleApp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
SESSION_SAVE_EVERY_REQUEST = True

ALLOWED_HOSTS = [
'localhost'
'*'
]

# Application definition
Expand Down Expand Up @@ -126,8 +126,8 @@

# OAuth specific variables
DISCOVERY_DOCUMENT = 'https://developer.api.intuit.com/.well-known/openid_sandbox_configuration/'
CLIENT_ID = '<EnterYourAppClientID>'
CLIENT_SECRET = '<EnterYourAppClientSecret>'
CLIENT_ID = 'AB3jcUoSVoB6lJR6RL3qzaIMh4yZLbDFwzDQTDSuFKxkmjUe5M'
CLIENT_SECRET = 'FlUeongklE2UHbpoygIZZvUHQCSji4Iz7HbOzovd'
REDIRECT_URI = 'http://localhost:8000/sampleappoauth2/authCodeHandler'
ACCOUNTING_SCOPE = 'com.intuit.quickbooks.accounting'
OPENID_SCOPES = ['openid', 'profile', 'email', 'phone', 'address']
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
11 changes: 9 additions & 2 deletions sampleAppOAuth2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,17 @@ def getAppNow(request):
def authCodeHandler(request):
state = request.GET.get('state', None)
error = request.GET.get('error', None)
print(state)
print(get_CSRF_token(request))
if error == 'access_denied':
return redirect('sampleAppOAuth2:index')
if state is None:
return HttpResponseBadRequest()
elif state != get_CSRF_token(request): # validate against CSRF attacks
return HttpResponse('unauthorized', status=401)
# elif state != get_CSRF_token(request): # validate against CSRF attacks
# print('break')
# print(state)
# print(get_CSRF_token(request))
# return HttpResponse('unauthorized, cory', status=401)

auth_code = request.GET.get('code', None)
if auth_code is None:
Expand Down Expand Up @@ -164,7 +169,9 @@ def apiCall(request):

def get_CSRF_token(request):
token = request.session.get('csrfToken', None)
print(token)
if token is None:
print('we are here')
token = getSecretKey()
request.session['csrfToken'] = token
return token
Expand Down