First Commit
This commit is contained in:
parent
897e9c33a1
commit
9712ec9062
|
@ -15,10 +15,10 @@ class IAMExample:
|
||||||
self.iamURL = 'https://accounts.dev.d4science.org/auth/realms/d4science/protocol/openid-connect/token'
|
self.iamURL = 'https://accounts.dev.d4science.org/auth/realms/d4science/protocol/openid-connect/token'
|
||||||
self.call = sys.argv[1]
|
self.call = sys.argv[1]
|
||||||
self.clientId = sys.argv[2]
|
self.clientId = sys.argv[2]
|
||||||
self.secret = sys.argv[3]
|
self.clientSecret = sys.argv[3]
|
||||||
print('Call: ' + self.call)
|
print('Call: ' + self.call)
|
||||||
print('ClientId: ' + self.clientId)
|
print('ClientId: ' + self.clientId)
|
||||||
print('Secret: ' + self.secret)
|
print('ClientSecret: ' + self.clientSecret)
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
if self.call== "AccessToken":
|
if self.call== "AccessToken":
|
||||||
|
@ -32,7 +32,7 @@ class IAMExample:
|
||||||
def getAccessToken(self):
|
def getAccessToken(self):
|
||||||
print("getAccessToken()")
|
print("getAccessToken()")
|
||||||
loginheaders = { 'Accept' : 'application/json', 'Content-Type' : 'application/x-www-form-urlencoded'}
|
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
|
# Get Access Token by client_id
|
||||||
resp1 = requests.post(self.iamURL, data=logindata, headers=loginheaders)
|
resp1 = requests.post(self.iamURL, data=logindata, headers=loginheaders)
|
||||||
|
@ -63,8 +63,7 @@ class IAMExample:
|
||||||
print("Resp2: ",jwt2)
|
print("Resp2: ",jwt2)
|
||||||
umaToken=jwt2["access_token"]
|
umaToken=jwt2["access_token"]
|
||||||
return umaToken
|
return umaToken
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'IAMExample'
|
return 'IAMExample'
|
||||||
|
|
Loading…
Reference in New Issue