Skip to content

Commit

Permalink
Updates authentification endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ATraineauAKA committed Apr 9, 2024
1 parent 7f79e9a commit e4ce53b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lowatt_grdf/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

from . import LOGGER, models

OPENID_ENDPOINT = "https://sofit-sso-oidc.grdf.fr/openam/oauth2/realms/externeGrdf"


def raise_for_status(resp: requests.Response) -> None:
try:
Expand All @@ -54,6 +52,11 @@ def scope(self) -> str:
def api(self) -> str:
raise NotImplementedError()

@property
@abc.abstractmethod
def auth_endpoint(self) -> str:
raise NotImplementedError()

def __init__(self, client_id: str, client_secret: str):
self.client_id = client_id
self.client_secret = client_secret
Expand Down Expand Up @@ -88,7 +91,7 @@ def access_token(self) -> str:

def _authenticate(self) -> tuple[str, float]:
resp = requests.post(
f"{OPENID_ENDPOINT}/access_token",
self.auth_endpoint,
data={
"grant_type": "client_credentials",
"client_id": self.client_id,
Expand Down Expand Up @@ -214,8 +217,14 @@ def donnees_techniques(self, pce: str) -> Any:
class StagingAPI(BaseAPI):
scope = "/adict/bas/v4"
api = "https://api.grdf.fr/adict/bas/v4"
auth_endpoint = (
"https://sofit-sso-oidc.grdf.fr/openam/oauth2/realms/externeGrdf/access_token"
)


class API(BaseAPI):
scope = "/adict/v2"
api = "https://api.grdf.fr/adict/v2"
auth_endpoint = (
"https://adict-connexion.grdf.fr/oauth2/aus5y2ta2uEHjCWIR417/v1/token"
)

0 comments on commit e4ce53b

Please sign in to comment.