How To
Summary
Use the following procedures to register and authenticate System Users to make API calls to IBM Food Trust™. This is a key step towards automating your data uploads to IBM Food Trust.
Objective
A System User is a automated program, or an application, that sends or receives data by specifying a Service ID/API Key token combination. A System User can be a combination of multiple programs, or applications, in which case they share the same token. Registering multiple System Users with IBM Food Trust can be useful for managing distinct workloads, such as processing certificates and sending messages, and to separate information types on your local system. To configure a new System User, you must first create a new Service ID/API Key pair. You will then register the System User with IBM Food Trust by defining its Service ID and API key in the Users UI module. Once registered, the System User will generate an IBM Food Trust Service token, in order to make authenticated API calls, using the following sequence: Attention: The specific process and detailed steps are described below. A one-time initial registration is required to allow a new System User to authenticate to IBM Food Trust. Only an Account Administrator for your Organization can register System Users. The Account Administrator must first create a unique Service ID and API key pair for each System User, as follows: After you have registered the new Service ID, the System User must generate an IBM Cloud IAM token using the following steps (an automated process): After obtaining an IBM Cloud IAM token, the System User must exchange it for an IBM Food Trust Service token: Windows users: Use an application such as Cygwin to run the following curl commands. Attention: The Organization ID is available from the SYSTEM IDS tab in the Users Module: Both the IBM Cloud IAM token and the IBM Food Trust Service token are encoded with an expiration time. During the token exchange, the expiration time is copied from the IBM Cloud IAM token and applied to the IBM Food Trust Service token, so they will both expire at the same time. If an expired IBM Cloud IAM token is sent with an exchange token request, it will be rejected. If an expired IBM Food Trust Service token is submitted with an API call, it will be rejected. The following code samples create an IBM Cloud IAM token and exchange it for an IBM Food Trust Service token. You can use these examples to configure automation: To resolve issues with System User configuration, use the following steps: Issue: Receiving a 404 response when exchanging an IBM Cloud IAM token for an IBM Food Trust Service token: Example Response: Action: Verify that the Service ID is registered as a System User in the IBM Food Trust Users module. Verify that the correct URL is being targeted in the CURL command: Command: North America: EU: Verify that the correct Organization ID is being specified in the CURL command. There are separate Organization IDs for each corresponding zone. For example, if targeting the Integration zone, you must provide the Integration zone Organization Id. Again, if the Organization ID is unknown for the corresponding zone, it can be found in the System Users
Configure a System User








Your downloaded and saved API key (JSON) should look similar to the following example:
json { "name": "Solution API key", "description": "My Solution API key", "createdAt": "2018-05-03T16:00+0000", "apiKey": "wZvu952...gcci" }



Obtain an IBM Cloud IAM token
North America: bash curl -X POST --header "Content-Type: application/x-www-form-urlencoded" --data "grant_type=urn:ibm:params:oauth:grant-type:apikey" --data "apikey=" https://iam.ng.bluemix.net/oidc/token
EU: bash curl -X POST --header "Content-Type: application/x-www-form-urlencoded" --data "grant_type=urn:ibm:params:oauth:grant-type:apikey" --data "apikey=" https://iam.eu-gb.bluemix.net/oidc/token<API_KEY> with the apiKey value from the JSON key file, and runs the command.
{
"access_token" : "eyJraWQiOiIyMDE3M...",
"token_type" : "Bearer",
"expires_in" : 3600,
"expiration" : 1523646898
}
Exchange an IBM Cloud IAM token for a Service token
North America: bash curl -X POST -H 'Content-Type: application/json' -d 'IAM_RESP_BODY' https://food.ibm.com/ift/api/identity-proxy/exchange_token/v1/organization/{ProductionOrganizationId}
EU: bash curl -X POST -H 'Content-Type: application/json' -d 'IAM_RESP_BODY' https://eu.food.ibm.com/ift/api/identity-proxy/exchange_token/v1/organization/{ProductionOrganizationId}IAM_RESP_BODY with the IBM Cloud IAM JSON object ("access_token" value) returned from the previous Obtain an IBM Cloud IAM token step.{organizationId} with the Organization ID and runs the command:
Example: (expanded JSON)
North America:
curl - X POST - H 'Content-Type: application/json' - d '
{
"access_token": "eyJraWQ...",
"refresh_token": "J1AV0...",
"token_type": "Bearer",
"expires_in": 3600,
"expiration": 1525367304
}
' https://food.ibm.com/ift/api/identity-proxy/exchange_token/v1/organization/38d1...
1. The System User receives a response similar to the following example: { "onboarding_token" : "eyJhbGciOiJSUzI1NiIsInR...", }
2. In the Authorization header of API calls, the System User specifies the onboarding_token key (in the JSON object returned by the command), as Bearer <token>. The token expires three hours after being issued:
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR...
Token Expiration
Code Samples
- Java
- IBM Integration Bus (IIB)
- TypescriptTroubleshooting
{
“ok”: false,
“statusCode”: 404,
“error”: “User Id: {SERVICE_ID} not found with solution Id: {SOLUTION_ID} and organization Id: {ORGANIZATION_ID}”
}
If the System ID is not registered, follow the instructions to Register a System User.bash curl -X POST -H 'Content-Type: application/json' -d 'IAM_RESP_BODY' https://food.ibm.com/ift/api/identity-proxy/exchange_token/v1/organization/{ProductionOrganizationId}bash curl -X POST -H 'Content-Type: application/json' -d 'IAM_RESP_BODY' https://eu.food.ibm.com/ift/api/identity-proxy/exchange_token/v1/organization/{ProductionOrganizationId}SYSTEM IDS tab under the User Management section of the UI.Related Topics
Related Information
Document Location
Worldwide
Was this topic helpful?
Document Information
Modified date:
18 October 2021
UID
ibm11075593