From 6c20ed6608cdc01f59ecdf679cbc251f0a85ee72 Mon Sep 17 00:00:00 2001
From: Luka Radenovic <luka@init.hr>
Date: Thu, 20 Jan 2022 09:11:40 +0100
Subject: [PATCH] Update get_token function

---
 helpers/hydra_oauth.py | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/helpers/hydra_oauth.py b/helpers/hydra_oauth.py
index 629225f4..06fdc3de 100644
--- a/helpers/hydra_oauth.py
+++ b/helpers/hydra_oauth.py
@@ -1,7 +1,5 @@
 from flask import request, session
 from requests_oauthlib import OAuth2Session
-from oauthlib.oauth2 import BackendApplicationClient
-from requests.auth import HTTPBasicAuth
 
 from config import *
 from helpers import HydraError
@@ -28,18 +26,15 @@ class HydraOauth:
     @staticmethod
     def get_token(state, code):
         try:
-            auth = HTTPBasicAuth(HYDRA_CLIENT_ID, HYDRA_CLIENT_SECRET)
-            client = BackendApplicationClient(client_id=HYDRA_CLIENT_ID)
-            hydra = OAuth2Session(client=client, state=state)
-            # hydra = OAuth2Session(
-            #     client_id=HYDRA_CLIENT_ID,
-            #     state=state,
-            # )
+            hydra = OAuth2Session(
+                client_id=HYDRA_CLIENT_ID,
+                state=state,
+            )
             token = hydra.fetch_token(
                 token_url=TOKEN_URL,
-                auth=auth,
                 code=code,
                 client_secret=HYDRA_CLIENT_SECRET,
+                include_client_id=True,
             )
 
             session["hydra_token"] = token
-- 
GitLab