An open API service indexing awesome lists of open source software.

https://github.com/simple-login/sdk.js

SimpleLogin JS SDK
https://github.com/simple-login/sdk.js

sdk simplelogin

Last synced: 12 months ago
JSON representation

SimpleLogin JS SDK

Awesome Lists containing this project

README

          

# SimpleLogin sdk.js

The [SimpleLogin](https://simplelogin.io) sdk.js library is created to facilitate adding SimpleLogin button to your webapp.

The SDK is based on [hello.js](https://github.com/MrSwitch/hello.js).

To use it, first include the SDK into the html and add the "Login with SimpleLogin" button:

```html
Login with Simplelogin

```

Second, use it to log user in. Please make sure to replace `{your SimpleLogin client-oauth-id}`.

```js
SL.init("{your SimpleLogin client-oauth-id}");

document.getElementById("btn-simplelogin").onclick = function(e) {
SL.login(function(user) {
console.log("got user from SL SDK", user);

document.getElementById("user-info").innerHTML = `
email: ${user.email}

name: ${user.name}

avatar:
`
})
}
```

Voilà, simple (as in SimpleLogin) isn't it 😉?

This example also included in [example](./example)

## Doc:

Adding the SDK will add the object `SL` to `window`. There are 2 main methods:

`SL.init("your oauth client id")`: init SDK

`SL.login(callback)`: once user is logged in, `callback` will be called with `user` as parameter.