Skip to main content

How to manage JWT token and consume APIs

Submitted by on

JSON Web Token (JWT) flow for External Partner

 

The client application is assumed to be a confidential client that can store the client application's private key. 

Two elements will be used in the JWT Flow

  • The X.509 certificate that matches with the client's private key (this private key must be registered in the Client Application Registry and NOT shared with anyone). The format must be of Base64 encoded public X.509 certificate
  • The clientId (also called issuer) which identifies the application

The API Gateway uses this certificate to verify the signature of the JWT claim and the issuer encrypted in the JWT bearer token to identify the caller (see how to build a JWT bearer token and how to request the token in the next pages)

Connexion flow :

SequenceFlow JWT

 

Authorization Server Endpoint depend on the gateway used

Ressouce Server Enpoint depend on the API targeted

 

 

 

How to built a JWT bearer token    

 

ForgeJWT assertion

 

Shcema

 

Some Dev tools for generating JWT assertion from dual private & public keys : Apigee partner enrolment journey_039755d6114243878207298a49d17403-281124-1035-2550_0.pdf

 

 How to request an access token

The client token request must be sent in an HTTP POST to the correct token endpoint : 

with the following parameters in the body (x-www-form-urlencoded) :

 
Parameterdescription
grant_typeRequired. Must be set to   urn:ietf:params:oauth:grant-type:jwt-bearer
assertionRequired. Must be set to the JWT bearer token, base64url-encoded

The form body is encoded in base64 (application/x-www-form-urlencoded)

Sample message:

POST /oauth/token HTTP/1.1

Content-Length:424

Content-Type:application/x-www-form-urlencoded; charset=UTF-8

Host:192.168.0.48:8080

grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiAiU2FtcGxlQ29uZmlk

Response (JSON ) should be :

HTTP/1.1 200 OK Cache-Control:no-store Content-Type:application/json Pragma:no-cache { "access_token":“O91G451HZ0V83opz6udiSEjchPynd2Ss9......", "token_type":"Bearer", "expires_in":« 180", }
 

You got the token (bearer) to access to the various API you are granted to. In the example before token = O91G451HZ0V83opz6udiSEjchPynd2Ss9...

 

 

HOW to Call A unitary API

Add the token received in the Header Authorization with the token_type as in the sample behind in the request to the ressource server (endpoint) attached to the APIs you want to target. Endpoints are provided in the detail API (see API CATALOG)


Sample message : 

POST /bnpapi/v1/store/inventory HTTP/1.1

Content-Type: application/soap+xml;charset=UTF-8;

action=« store"

Authorization: Bearer O91G451HZ0V83opz6udiSEjchPynd2Ss9.....

Host: host:port

Content-Length: 1103

… (body)

 

The token can be used during all this lifetime (check expirer_in in seconds). 

Before expiration request a new token. 

if the token becomes invalid (return code 401) you have to request a new token 

 

Tags

How to manage application

Submitted by on
APIGEE

This article is dedicated to give the keys and processes to manage consumption of APIs on BNPP PF API Management Platform

Prequisites : you need to get an access to this Dev Portal.

  1. APPLICATION CREATION : https://devportal.pf.api.staging.bnpparibas/application_creation
  2. HOW TO CONFIGURE MTLS AUTHENTICATION : https://devportal.pf.api.staging.bnpparibas/MTLS_APP_CONNEXION
  3. HOW TO CONSUME API ON MTLS AUTHENTICATION : https://devportal.pf.api.staging.bnpparibas/consume_mtls
  4. HOW TO CONFIGURE JWT AUTHENTICATION : https://devportal.pf.api.staging.bnpparibas/JWT_Configuration
  5. HOW TO CONSUME API ON JWT AUTHENTICATION : https://devportal.pf.api.staging.bnpparibas/JWT_assertion
  6. HOW TO GENERATE AUTO SIGNED DUAL KEYS : https://devportal.pf.api.staging.bnpparibas/open_ssl 

 

 

Tags