First Commit

This commit is contained in:
Giancarlo Panichi 2023-02-01 17:47:25 +01:00
parent 897e9c33a1
commit 9712ec9062
1 changed files with 4 additions and 5 deletions

View File

@ -15,10 +15,10 @@ class IAMExample:
self.iamURL = 'https://accounts.dev.d4science.org/auth/realms/d4science/protocol/openid-connect/token'
self.call = sys.argv[1]
self.clientId = sys.argv[2]
self.secret = sys.argv[3]
self.clientSecret = sys.argv[3]
print('Call: ' + self.call)
print('ClientId: ' + self.clientId)
print('Secret: ' + self.secret)
print('ClientSecret: ' + self.clientSecret)
def main(self):
if self.call== "AccessToken":
@ -32,7 +32,7 @@ class IAMExample:
def getAccessToken(self):
print("getAccessToken()")
loginheaders = { 'Accept' : 'application/json', 'Content-Type' : 'application/x-www-form-urlencoded'}
logindata = { 'grant_type' : 'client_credentials', 'client_id' : self.clientId, 'client_secret' : self.secret}
logindata = { 'grant_type' : 'client_credentials', 'client_id' : self.clientId, 'client_secret' : self.clientSecret }
# Get Access Token by client_id
resp1 = requests.post(self.iamURL, data=logindata, headers=loginheaders)
@ -63,8 +63,7 @@ class IAMExample:
print("Resp2: ",jwt2)
umaToken=jwt2["access_token"]
return umaToken
def __str__(self):
return 'IAMExample'