Created
February 1, 2019 12:54
-
-
Save maxux/575816bc629ed89a234137889ffb90ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import requests | |
def generatetoken(clientid, clientsecret, organization=None, validity=None): | |
params = { | |
'grant_type': 'client_credentials', | |
'client_id': clientid, | |
'client_secret': clientsecret, | |
'response_type': 'id_token', | |
'scope': 'offline_access' | |
} | |
if validity: | |
params['validity'] = validity | |
if organization: | |
params['scope'] = 'user:memberof:{},offline_access'.format(organization) | |
url = 'https://itsyou.online/v1/oauth/access_token' | |
resp = requests.post(url, params=params) | |
resp.raise_for_status() | |
return resp.content.decode('utf8') | |
if __name__ == '__main__': | |
clientid = "XXXXX" | |
clientsecret = "XXXXX" | |
parser = argparse.ArgumentParser(description='jwt tokenizer') | |
parser.add_argument('--organization', type=str, help='organization', required=True) | |
parser.add_argument('--validity', type=str, help='validity time') | |
args = parser.parse_args() | |
token = generatetoken(clientid, clientsecret, args.organization, args.validity) | |
print(token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment