Einstein Platform Services

Create the Apex Classes

In this step, you create the Apex classes that call the API and do all of the heavy lifting.

  1. In Salesforce, from Setup, enter Apex Classes in the Quick Find box, then select Apex Classes.

  2. Click New.

  3. To create the JWT Apex class, copy all the code from JWT.apex into the Apex Class tab and click Save.

  4. To create the JWTBearerFlow Apex class, go back to to the Apex Classes page, and click New.

  5. Copy all the code from JWTBearer.apex to the Apex Class tab and click Save.

  6. To create the HttpFormBuilder Apex class, go back to the Apex Classes page, and click New.

  7. Copy all the code from HttpFormBuilder.apex into the Apex Class tab and click Save.

  8. To create the Vision Apex class, go back to the Apex Classes page, and click New.

  9. Copy all the code from Vision.apex into the Apex Class tab and click Save.

  10. To create the VisionController Apex class, go back to the Apex Classes page, and click New.

  11. Copy the VisionController code from the apex-utils README.md into the Apex Class tab. This class is all the code from public class VisionController { to the closing brace }. In this example, the expiration is one hour (3600 seconds).

  12. Update the jwt.sub placeholder text of [email protected] with your email address. Use your email address that’s contained in the Salesforce org you logged in to when you created an account.

Warning

Use your email address that’s contained in the Salesforce org you logged in to when you created an account. Be sure to use your email address and not your Salesforce username.

  1. Click Save.
 // Get a new token
 JWT jwt = new JWT('RS256');
 // jwt.cert = 'JWTCert'; // Uncomment this if you used a Salesforce certificate to sign up for an Einstein Platform account
 jwt.pkcs8 = keyContents; // Comment this if you are using jwt.cert
 jwt.iss = 'developer.force.com';
 jwt.sub = '[email protected]';
 jwt.aud = 'https://api.einstein.ai/v2/oauth2/token';
 jwt.exp = '3600';

Updated less than a minute ago

Create the Apex Classes


In this step, you create the Apex classes that call the API and do all of the heavy lifting.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.