An Auth instance is first required in order to create the UserClient needed to interact with the SDK.
Websites that are loading the CDN copy of Users can implement a very basic vanilla JavaScript connection with the following code snippet.
<script type="text/javascript">
var auth = null;
var users = null;
window['nitroAuth'].init({
clientId: 'YourClientId',
scope: 'openid offline',
}, window.localStorage, function(a) {
auth = a;
window['nitroUsers'].init(auth, function(u) {
users = u;
// UserClient and Auth are now available!
});
});
</script>
A JavaScript module application could accomplish the same thing like this.
import { Auth } from '@nitropay/sdk/src/auth';
import { UsersClient } from '@nitropay/sdk/src/users';
const auth = new Auth({
clientId: 'YourClientID',
scope: 'openid offline'
});
const users = new UsersClient(auth);