This demo shows how to add Streetcred API calls into a nodejs app with our service client. It also shows a webhook implementation can create automated workflows in your app.
In this simple use case, you control a (very simple) issuer portal for your organization, which can issue a business card to anyone with a mobile wallet in your organization. Once a business card is issued, that holder can do business card verifications to other peers using the Streetcred mobile app.
-
Clone the repository
git clone https://github.com/streetcred-id/issuer-reference-app
-
Navigate into the directory
cd issuer-reference-app
-
Install the dependencies
npm install
-
Open up the repository in a code editor of your choice
-
Rename the .env-template file to .env
-
Go to the Streetcred developer portal and create an account
-
Create a new organization and select the Sovrin Staging Network.
-
In the .env file, add your organization's subscription key to the
SUBKEY
field and the access token to theACCESSTOK
field.
-
Retrieve your organization's Access Token and Subscription Key on the Organization page
-
Navigate to the
POST /definitions/credentials/{SchemaId}
endpoint -
Click the lock button on the right-hand side of the endpoint description and authorize Swaggerhub by pasting "Bearer " + your access token in the
accessToken
field, your subscription key in thesubscriptionKey
field, and clicking authorize for each field- i.e. If the access token is
123456789
, then enter it asBearer 123456789
- i.e. If the access token is
-
Close the authorization modal, and click the
Try it out
button to prepare the API call to write the credential definition to the ledger -
In the .env file, find the ledger you're using and remove the
#
from before that SCHEMA_ID line -
Copy that schema ID into the
schema_id
field in Swaggerhub -
Click "execute" and after a couple seconds you will see "curl", "request URL", and "server response". Copy the
definitionId
value from the "server response" section and add it to your .env file for the CRED_DEF_ID value -
If you get a 504 Gateway Timeout error, go to the GET /definitions/credentials endpoint, click
try it out
and thenexecute
to get your newly minted credential definition
After defining the credential, you are ready to run the application.
-
Run with npm
npm start
-
On the web app, fill in the details and click issue credential
-
If you're using the Streetcred Wallet, make sure your agent is configured to the Sovrin Staging network (upper-left on the home tab)
-
Scan the QR with your mobile wallet
This is a connection invitation. Webhooks will automatically issue you a credential once this is scanned
-
Accept the credential offer
-
Receive a business card!
-
If you are on iOS, you can also use the Streetcred Identity Agent to connect with others and send verified email and phone number between each other
Contact [email protected] for any questions.