From 6232506e1b9fef6d55fdf4ce51635769a588c689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esm=C3=A9=20Middaugh?= <37889895+middaugh@users.noreply.github.com> Date: Thu, 1 Jun 2023 09:37:28 +0200 Subject: [PATCH] Fix TypeError returned when insufficient Authorization If app doesn't have authentication rights, then the code sends a type error. Fixed by wrapping casting response.content to string -- user can then see the authorization error message in the app. Error: SampleOAuth2_UsingPythonClient\app\views.py", line 122, in qbo_request return HttpResponse(b' '.join([response.content, str(response.status_code)])) TypeError: sequence item 1: expected a bytes-like object, str found --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index 52e7809..f8c7f92 100644 --- a/app/views.py +++ b/app/views.py @@ -119,7 +119,7 @@ def qbo_request(request): response = qbo_api_call(auth_client.access_token, auth_client.realm_id) if not response.ok: - return HttpResponse(' '.join([response.content, str(response.status_code)])) + return HttpResponse(' '.join([str(response.content), str(response.status_code)])) else: return HttpResponse(response.content)