slug | title | description |
---|---|---|
/products/rarime/guide-issuing-credentials-to-rarime |
Issuing credentials to RariMe users |
Learn how to use rarime-connector library to offer your credentials to RariMe users. |
import IdealImage from '@site/src/components/IdealImage';
:::tip If you still need to learn to issue Rarimo credentials, see Setting Up A Credentials Issuer. :::
After issuing Rarimo credentials, you need to serve them to the users. To do that, we'll integrate RariMe snap into your DApp.
Install the RariMe connector package:
yarn add @rarimo/rarime-connector
Create a connector instance:
import { enableSnap } from '@rarimo/rarime-connector'
async function createConnector() {
const snap = await enableSnap() // connects to the snap or installs it
const connector = await snap.getConnector()
return connector
}
To fetch the credential from the issuer, we need to form a claim offer:
// get the claim type from your schema
const CLAIM_TYPE = 'urn:uuid:6dff4518-5177-4f39-af58-9c156d9b6309'
const ISSUER_DOMAIN = 'https://issuer.example.com'
const connector = await createConnector()
const { identityIdString } = await connector.createIdentity()
const { data: claimOffer } = await fetch(
`https://${ISSUER_DOMAIN}/v1/credentials/${identityIdString}/${CLAIM_TYPE}`
).then((res) => res.json())
Once we have the claim offer, we can prompt the user to save the credential to RariMe. To do that, we'll use the saveCredentials
method of the connector instance:
await connector.saveCredentials(claimOffer)
The user will be prompted to save the credential to RariMe:
:::tip Keep the UX transparent: show the prompt only after the user explicitly clicks on the Add credential button or a similar UI element. :::
<IdealImage img={require('/img/rarime-add-credential.png')} alt="RariMe prompt" />