trailhead

Set Up Your Environment

Learning Objectives

After completing this unit, you’ll be able to:
  • Create an Einstein Platform Services Account.
  • Generate a JWT access token to call the API.

Get an Einstein Platform Services Account

Before you can access the Einstein Platform Services APIs, you first create an account and download your key. You can skip this step if you already have an account and key.

If you’ve completed the Quick Start: Einstein Image Classification project or the Build a Cat Rescue App That Recognizes Cat Breeds project, you likely already have an account and key.

When you sign up for an account, you’re prompted to log in to your Salesforce org. For this module, you use the username and password for your hands-on Trailhead Playground (TP) org. If you don’t know what a Trailhead Playground org is, or you need to find your TP username and password, check out the Trailhead Playground Management module.

After you log in, you’re prompted to allow the sign-up page to access information in your Salesforce org. Giving access lets the sign-up page retrieve some basic information such as your ID, profile, email, address, and phone number. After your account is created, you can download your key.

  1. Navigate to the sign-up page at https://api.einstein.ai/signup.
    Warning

    Warning

    Be sure you’re logged out of Salesforce before you go through the steps to get an account. That way, you can be sure you’re giving access to the right Salesforce org when you sign up.

  2. Click Sign Up Using Salesforce.
    The Einstein Platform Services sign up page.
  3. On the Salesforce login page, type your Trailhead Playground username and password and click Log In.
    The Salesforce login page.
  4. Click Allow so the page can access basic information, such as your email address, and perform requests.
    The page that requests access to your Salesforce org.
  5. On the activation page, if you’re using Chrome, click Download Key to save the key locally. The key file is named einstein_platform.pem. If you’re using any other browser, cut and paste your key from the browser into a text file and save it as einstein_platform.pem.
    The page where you download your private key.
    Warning

    Warning

    The Download Key button is only supported in the most recent version of Google Chrome™. If you're using a different browser, you can cut and paste your key into text a file and save it as einstein_platform.pem.

Install cURL

cURL is a free command line tool for getting or sending data using URL syntax. It comes in handy when working with REST endpoints. You use cURL throughout this module to make calls to the Einstein Intent API.

If you already have cURL installed, you can skip this step. The Linux or Mac OSX operating systems have cURL installed by default, but if you use Windows you have to install it yourself.

To install cURL, go to https://curl.haxx.se/download.html. Download and install the version for your operating system.

Generate a Token

The Einstein Platform Services APIs use OAuth 2.0 JWT bearer token flow for authorization. This means that you need a valid token in each call you make to the API.
When you call the API in code, you write code to generate the access token. In this module though, you use the token web page UI to generate a token.
  1. In your browser, navigate to the token page at https://api.einstein.ai/token.
  2. Type your email address. This is the email address associated with your user in the Trailhead Playground org you logged in to when you signed up for an account. Be sure to use your email address and not your Trailhead Playground username.
  3. Click Choose File or Browse and navigate to the einstein_platform.pem file you downloaded when you signed up for an account.
  4. Set the Expiration in Mins to 90. The token will expire after 90 minutes, which is enough time to complete this module. If you want your token to be valid longer, increase the number of minutes.
  5. Click Get Token, and save the token in a text file or somewhere you can access it.
    The page to generate a token

Resources

retargeting