ID4i provides globally unique IDs for single workpieces and a platform to manage, and exchange data bound to IDs in an inter-organizational manner. For details, please refer to http://id4i.de.
This repository contains all example C# .Net API Client for ID4i. For detailed documentation of ID4i see https://backend.id4i.de/docs/reference/en/reference.html#_tutorials
The sources of the client library we use to connect to ID4i along with further documentation is available here: https://github.com/BlueRainSoftware/id4i-api_client-csharp
To be able to connect to ID4i with an API client, you need to register and set up an API key for
your application first. Using this key, you can sign JWTs to send as Authorization
header for
subsequent requests.
-
If you do not already have an ID4i sandbox account, please register at https://sandbox.id4i.de and log in.
-
Navigate to
API Keys
and selectNew API Key
-
Give your key a label and enter an application secret (or let the application generate one for you). [1]
-
Save your secret resp. your public key in a secure location. For security reasons, you won’t be able to display this key again in ID4i.
-
Activate the key on the details page
Warning
|
Do not store your API Keys and Secrets with the source code of your application. Either supply the key as a configuration property of your application or retrieve it from your own server when required in the application. Use a separate API Key for each deployment of your application. |
Once you have set up your API key, you need to set the environment variables ID4I_API_KEY
and ID4I_API_SECRET
to reflect your key.
You can then run the project using dotnet run
.
You should see some information about the version running on the https://sandbox.id4i.de now:
$ dotnet run
class AppInfoPresentation {
Branch: sandbox
CommitTime: 2018-03-16T14:51:47+0000
Name: ID4i
Revision: 4584e5c
Version: 0.6.0
}
dotnet new console -o ID4iClientSample
dotnet add package BlueRain.ID4i
dotnet add package System.IdentityModel.Tokens.Jwt
We provide a Dockerfile
to run the build on non-windows machines. To build the container and run the sample, do the following.
$ docker build -t id4i-csharp-sample:latest .
Step 1/5 : FROM microsoft/dotnet:1-sdk
---> 6946b52e7215
Step 2/5 : WORKDIR /app
---> Using cache
---> 4ce559a3c5b1
Step 3/5 : COPY ID4iClientSample/* /app/
---> Using cache
---> 6391678eb4ba
Step 4/5 : RUN dotnet restore
---> Using cache
---> fa0829d486fb
Step 5/5 : RUN dotnet build
---> Using cache
---> f5ebc4895e10
Successfully built f5ebc4895e10
Successfully tagged id4i-csharp-sample:latest
# built successfully, now run
$ docker run \
-e ID4I_API_KEY=<your API key> \ (1)
-e ID4I_API_SECRET=<your API key secret> \ (2)
id4i-csharp-sample \ (3)
dotnet run (4)
{
"name": "ID4i",
"revision": "3089680",
"branch": "sandbox",
"commitTime": "2018-04-23T13:12:13+0000",
"version": "0.6.0",
"productionMode": true
}
-
A valid API Key, this is passed to the container as environment varibale
-
Your API key secret, required to sign the JWT. Exposed in the container’s environment as well
-
The image to start
-
The command to run in the image