O'Reilly logo

Learning Salesforce Einstein by Mohith Shrivastava

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

JWT Bearer token exchange

The next step is to make an HTTP POST callout with the body assertion obtained in the previous section. The following is the code for the same (you can view the entire code at https://github.com/PacktPublishing/Learning-Salesforce-Einstein/blob/master/Chapter6/SalesforceEinsteinVision/src/classes/EinsteinVisionJWTBearerTokenExchange.cls):

     public static String getAccessToken(String accountId,         Integer expirationTime, String privateKeyString ) {       String tokenendPoint =          'https://api.metamind.io/v1/oauth2/token';       String access_token = null;       String body =          'grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-          bearer&assertion='+ EinsteinVisionJWT.issue          (accountId,expirationTime,privateKeyString); HttpRequest req ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required