Update get_token function
This commit is contained in:
parent
9771ae8060
commit
6c20ed6608
1 changed files with 5 additions and 10 deletions
|
@ -1,7 +1,5 @@
|
||||||
from flask import request, session
|
from flask import request, session
|
||||||
from requests_oauthlib import OAuth2Session
|
from requests_oauthlib import OAuth2Session
|
||||||
from oauthlib.oauth2 import BackendApplicationClient
|
|
||||||
from requests.auth import HTTPBasicAuth
|
|
||||||
|
|
||||||
from config import *
|
from config import *
|
||||||
from helpers import HydraError
|
from helpers import HydraError
|
||||||
|
@ -28,18 +26,15 @@ class HydraOauth:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_token(state, code):
|
def get_token(state, code):
|
||||||
try:
|
try:
|
||||||
auth = HTTPBasicAuth(HYDRA_CLIENT_ID, HYDRA_CLIENT_SECRET)
|
hydra = OAuth2Session(
|
||||||
client = BackendApplicationClient(client_id=HYDRA_CLIENT_ID)
|
client_id=HYDRA_CLIENT_ID,
|
||||||
hydra = OAuth2Session(client=client, state=state)
|
state=state,
|
||||||
# hydra = OAuth2Session(
|
)
|
||||||
# client_id=HYDRA_CLIENT_ID,
|
|
||||||
# state=state,
|
|
||||||
# )
|
|
||||||
token = hydra.fetch_token(
|
token = hydra.fetch_token(
|
||||||
token_url=TOKEN_URL,
|
token_url=TOKEN_URL,
|
||||||
auth=auth,
|
|
||||||
code=code,
|
code=code,
|
||||||
client_secret=HYDRA_CLIENT_SECRET,
|
client_secret=HYDRA_CLIENT_SECRET,
|
||||||
|
include_client_id=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
session["hydra_token"] = token
|
session["hydra_token"] = token
|
||||||
|
|
Loading…
Reference in a new issue