Example Web SDK Integration

Django Implementation of HumanID SSO

Developer Console

Acquire CLIENT-ID, CLIENT-SECRET, and set-up redirect URLs on the App Details page by registering your app through https://developers.human-id.org/home/.

WebLoginUrl API Call

Create a view function that will perform a POST API request and render HTML:

#YOUR_APP/views.py
def homepage(request):
    headers = {'client-id':'CLIENT_ID','client-secret':'CLIENT_SECRET'}
    response=requests.post('https://core.human-id.org/v0.0.3/server/users/web-login',headers=headers)
    data=response.json()
    return render(request,'trial/homepage.html',
    {
        'data':data
    })

Create a HTML page:

<!YOUR_APP/templates/homepage.html>
{%block content%}
<div>
<p>{{data}}</p>
<p><a href={{data.data.webLoginUrl}}>{% include 'anonymous-login.svg.html'%}</a></p>
</div>
{%endblock%}

Callback URL

After a user successfully logs in through humanID. The user will be redirected to the URL specified in the developer console on the App Details page.

Create a function that will take the exchange token in that URL and make another API request to acquire a unique User ID.

#YOUR_APP/views.py
def callback(request):
    headers = {'client-id':'CLIENT_ID','client-secret':'CLIENT_SECRET'}
    token = request.GET.get('et')
    response= requests.post('https://core.human-id.org/v0.0.3/server/users/exchange',headers= headers,data={'exchangeToken':token})
    data=response.json()
    return render(request,'trial/callback.html',
    {
        'data':data
    })

Last updated