Notifly
Search…
Authentication
The widget expects an authCode to be included as part of the config object. The value of the the authentication code should be a hash of your application's secret and the user's externalId field using the HMAC-SHA256 hashing function. The Notifly server also computes the hash value and checks that the two values match. If successful the server returns a token which is then used to authenticate future requests. If the hashes do not match the server returns 401 status code.
Code examples
Python
Javascript (Node.js)
Ruby
1
import hashlib
2
import hmac
3
4
authCode = hmac.new(
5
NOTIFLY_APP_SECRET.encode('utf-8'),
6
str(user.id).encode('utf-8'),
7
digestmod=hashlib.sha256,
8
).hexdigest()
9
10
# The `.encode` here assume that you use Python 3
11
# and that `NOTIFLY_APP_SECRET` is a `str`-object
12
# (which would be `unicode` in Python 2).
Copied!
1
const crypto = require('crypto');
2
const hmac = crypto.createHmac('sha256', NOTIFLY_APP_SECRET);
3
hmac.update(user.id);
4
5
// WARNING: Never calculate this in the frontend!
6
// It would expose your Notifly app secret and
7
// allow users to send arbitrary notifications
8
// to all users of your app.
Copied!
1
require 'openssl'
2
3
OpenSSL::HMAC.hexdigest('sha256', NOTIFLY_APP_SECRET, user.id)
Copied!
Copy link