add external configuration to the api-client
This commit is contained in:
parent
a1f32ecd02
commit
3c4dfb9f24
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.idea/
|
||||
**/__pycache__/
|
||||
**/.env*
|
||||
|
@ -1,6 +1,19 @@
|
||||
from requests_oauthlib import OAuth2Session
|
||||
from oauthlib.oauth2 import BackendApplicationClient
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
environment_name = os.getenv('ENV_NAME', 'qa') # need to find a place for this
|
||||
dotenv_path = f'.env.{environment_name}'
|
||||
load_dotenv(dotenv_path)
|
||||
|
||||
client_id = os.getenv('CLIENT_ID')
|
||||
client_secret = os.getenv('CLIENT_SECRET')
|
||||
token_url = os.getenv('TOKEN_URL')
|
||||
username = os.getenv('USERNAME')
|
||||
password = os.getenv('PASSWORD')
|
||||
audience = os.getenv('AUDIENCE')
|
||||
scope = os.getenv('SCOPE', '').split(',')
|
||||
|
||||
def get_token(client_id, client_secret, token_url, username, password, audience, scope):
|
||||
client = BackendApplicationClient(client_id=client_id)
|
||||
|
8
env_template
Normal file
8
env_template
Normal file
@ -0,0 +1,8 @@
|
||||
URL=https://api.dummy.com
|
||||
CLIENT_ID=client_id
|
||||
CLIENT_SECRET=client_secret
|
||||
TOKEN_URL=oauth_token_fetch_url
|
||||
USERNAME=username
|
||||
PASSWORD=password
|
||||
AUDIENCE=intended_audience
|
||||
SCOPES=scope1,scope2
|
@ -1,3 +1,4 @@
|
||||
oauthlib~=3.2.2
|
||||
requests~=2.32.3
|
||||
requests-oauthlib~=2.0.0
|
||||
requests-oauthlib~=2.0.0
|
||||
python-dotenv~=1.0.1
|
Loading…
Reference in New Issue
Block a user