Skip to main content
Participant
October 12, 2022
Question

Obtaining JWT with API request

  • October 12, 2022
  • 1 reply
  • 792 views
  1. Is there a way to obtain the JWT token via API, in a single call, without using Node, Java or PHP? (ex.  Postman)
  2. Which is the correct metaScopes to use into the config.js in Node JWT test, when using PDF Services API? I tried with metaScopes : "ent_user_sdk" but it's wrong and don't understand why.

 

Thanks

    This topic has been closed for replies.

    1 reply

    Raymond Camden
    Community Manager
    Community Manager
    October 12, 2022

    I believe you want this: 

     
    Here's a Python func that gets the access token - technically not the JWT, but if you are trying to call the new REST APIs, this will work:
     
    def getAccessToken(creds):
    	url = "https://ims-na1.adobelogin.com/ims/exchange/jwt"
    
    	jwtPayloadRaw = f"""
    	{{ 
    		"iss": "{creds['org_id']}",
    		"sub": "{creds['technical_account_id']}",
    		"https://ims-na1.adobelogin.com/s/ent_documentcloud_sdk": true,
    		"aud": "https://ims-na1.adobelogin.com/c/{creds['client_id']}" 
    	}}
    	"""
    
    	jwtPayloadJson = json.loads(jwtPayloadRaw)
    	jwtPayloadJson["exp"] = datetime.datetime.utcnow() + datetime.timedelta(seconds=30)
    
    	accessTokenRequestPayload = {
    		'client_id': creds['client_id'],
    		'client_secret': creds['client_secret']
    	}
    
    
    	jwttoken = jwt.encode(jwtPayloadJson, KEY, algorithm='RS256')
    
    	accessTokenRequestPayload['jwt_token'] = jwttoken
    	result = requests.post(url, data = accessTokenRequestPayload)
    	resultjson = json.loads(result.text)
    
    	return resultjson['access_token']
    
     
    Participant
    February 26, 2023

    I tried the above, but it always gives error 'Could not deserialize key data. The data may be in an incorrect format or it may be encrypted with an unsupported algorithm'

    Raymond Camden
    Community Manager
    Community Manager
    February 27, 2023

    If you dumnp out result.text, what do you see?