Signature
Required Class: Signature Class
Generating a Signature
Smile ID requires you to send a unique signature and timestamp with every job you conduct. Although running jobs using any of our libraries will automatically compute the signature, there may be occasions when you wish to execute a job using our REST API or generate signatures yourself. In such cases, you can use the sample code below to calculate a signature:
require 'smile-identity-core'
# Initialise
partner_id = '<Put your partner ID here>'; # log in to the Smile ID portal to find your partner id
api_key = '<Put your API key here>'; # copy your API key from the Smile ID portal
connection = SmileIdentityCore::Signature.new(partner_id, api_key)
# Generate a signature
signature = connection.generate_signature('<put your custom timestamp>') # where the timestamp is optional
Response
The response will be in the form of a hash:
{
:signature => "<the generated signature>",
:timestamp => "2022-03-13T11:44:10.231Z"
}
Confirming an Incoming Signature
To verify that the response you receive from your callback is genuinely from Smile ID, you can confirm the returned signature and timestamp. Use the sample code below to confirm the signature:
require 'smile-identity-core'
# Initialise
partner_id = '<Put your partner ID here>'; # log in to the Smile ID portal to find your partner id
api_key = '<Put your API key here>'; # copy your API key from the Smile ID portal
connection = SmileIdentityCore::Signature.new(partner_id, api_key)
# Confirm a signature
signature = connection.confirm_signature('<put the received timestamp>', '<put the received signature>')
Response
The response will be a boolean:
true or false
Last updated
Was this helpful?