Adobe IO : JWT authentication with Python

On this article, I will guide you to create an JWT (JSON Web Token) authentication for Adobe. My example will be based on the Admin Console, the user management, because this is one of the few that are supporting the JWT authentication at the moment.

Everything that is going to be explained now is a comprehensive explanation of the documentation available by Adobe : https://github.com/adobeio/adobeio-documentation/blob/master/auth/JWTAuthenticationQuickStart.md

JSON Web Token Explanation

What is JWT ? It is an acronym that stands for JSON Web Token. You send a signed JSON to a service and it returns you a token.

It is much better than the Oauth authentication provided at the moment from Adobe, as the latter forces you to manually load a URL in your browser to retrieve the token. So much for automation.

I always believed that an API should be able to run without any human interference, or as little as possible. JWT identification enables this possibility.

What is required for my JWT ?

First of all, you need to make sure that you have created a connection to the Adobe IO User Management Module with the correct configuration and you still have your private key in order to log to that module.

Don’t worry, we are going to do that together in the following part.

Creating an account with Adobe IO console

You would need to go to integration console interface in order to register your application : https://console.adobe.io/integrations
Then you need to click on “New Integration”

You can click on “new Integration”

The next steps is to actually setup an access to the application of your choice.
On my side, as I explained earlier, I will create a user management API access.

Select that you want to access an API
Declare that you want to connect to the User Management API

The User Management API has been selected for this demo as it supports the JWT authentication at the moment of that writing (January 2019). In the future, all of the API will support the JWT method. So depending on when you read this tutorial, you may be able to select any API you want.

Normally, if it is your first API, nothing to update

On the next step, you will provide the key that you have prepared for the connection. The certificate that are supported are .crt, .perm and .der

Here you need write the description and import the key

The full description on how to generate this public key is available on this blog post : generate a CRT file on windows.
Make sure that you have generated the private key and also have a copy unencrypted for your own use.

Information to retrieve from your account

When the account has been created, you will see a possibility to click on it on the IO console.
You can click on that and retrieve these information :

  • Your ORG ID
  • Your API KEY
  • Your TECH ID (something with @tech…)
  • Your secret

On top of that, the endpoint that is required for the JWT token creation.
That endpoint being : https://ims-na1.adobelogin.com/ims/exchange/jwt

Python Code

python Configuration

On top of the configuration you have done for your adobe account, you would need to have several libraries installed on your python environment :

  • requests (pip install requests)
  • jwt (pip install jwt)

As you have your private key available, you will need it to be accessible for your program.

JWT with requests and token retrieval

The code requires to retrieve the JWT is the following :

You now have retrieved the token using the JWT authentication method.
As explained before, using this method enable you to bypass human interaction to use the Adobe IO API. Therefore, you can create cron job in order to realize operation at regular time.

I hope this tutorial was helpful and don’t hesitate if you have a question.

Leave a Reply

Your email address will not be published. Required fields are marked *