Overview

Login Flow

Here's how it works:

  1. The user clicks a redirection url from your app, sending them to the HandCash.

  2. HandCash will ask the user if they would like to grant permissions to your app; The user can accept or decline access.

  3. The user will then be redirected, from HandCash back to your app.


Code

To authenticate a user, generate a redirection url using the SDK:

const {HandCashConnect} = require('@handcash/handcash-connect');
const handCashConnect = new HandCashConnect({ 
   appId: '<app-id>', 
   appSecret: '<secret>',
});

// Use this field to redirect the user to the HandCash authorization screen.
const redirectionLoginUrl =  handCashConnect.getRedirectionUrl();

If you need to pass any extra parameters, use the following syntax:

handCashConnect.getRedirectionUrl({'state': 'xyz'});

Any extra parameters will be passed back to your app upon redirect.


The Redirect

Serving the url to the user will redirect them to HandCash, who will then prompt the user to grant permissions for your app.

Once the user selects accept or decline, they will be redirected back your app's Authorization Success URL or Authorization Failed URL.

While redirecting, an authToken query parameter will be added to the request:

<auth-success-url>?authToken=<token>*

*plus any extra params

Use the authToken to view and spend as directed by the user.


Did this page help you?