How to use Nxter Sigbro Auth - Nxter/nxter-sigbro-auth GitHub Wiki
First of all you need to decide how will you use Sigbro Auth on your site. You can use our Wordpress plugin or make your own extension or module.
Wordpress plugin
This is very simple plugin for the Wordpress. You can test it on the Nxter. You can find the instruction in this repository.
Your own way
- You have to generate unique UUID for every new session
- Send POST request:
curl -XPOST https://random.nxter.org/api/auth/new -H "Content-Type: application/json" -d '{ "uuid" : "YOUR_UUID" }'
OK: {"result": "ok", "msg": "Your unique id ready for signing."}
FAIL: {"result": "fail", "msg": "Incorrect UUID in request"}
- Make SSE connection with
https://random.nxter.org:9040/stream
and subscribe to the event id with UUID code you used on the first step. You need to handle several json fields:
var source = new EventSource('https://random.nxter.org:9040/stream');
source.addEventListener(uuid, function (event) {
});
OK: type = 'success' && accountRS='ARDOR-....' && uuid = 'YOUR_UUID' && message = Token is valid'
FAIL: type = 'error' && message = 'Error message' && uuid = 'YOUR_UUID'
- And you need to send created token and send it to the API
curl -XPOST https://random.nxter.org/api/auth/update -H "Content-Type: application/json" -d '{ "uuid" : "YOUR_UUID", "token" : "your_full_token" }'
FAIL: result = 'fail' && msg = 'fail description'
OK: result = 'ok' && msg = 'All Right. Wait for the page reloading, please.'
If you received result = 'ok'
you need to wait new event on the client with accountRS of the user and authorise him.