@bhc/bhcauthsdk
v1.0.28
Published
```bash npm i -s @bhc/bhcauthsdk ```
Downloads
45
Readme
install
npm i -s @bhc/bhcauthsdk
import
// in node
const bhcAuth = require('@bhc/bhcauthsdk').bhcAuth
usage
create a user
let auth = new bhcAuth(client_id, client_secret);
auth.createUser(user_login, user_password).then(user => {
});
login
let auth = new bhcAuth(client_id, client_secret);
auth.login(user_login, user_password).then(user => {
console.log(user.getInfoUser());
});
bhcAuth
methods
constructor(client_ID, client_secret)
async createUser(username, password) //create a new user
async login(username, password) // login a user. return a User object
async refresh(refresh_token) // use a refresh_token to log a user
async verify(access_token) // verify the authenticity of a a token
verifyProvidedSource(access_token) // verify if the token was provided by you. A valid token may be provided by someone else, use this to ensure the token doesnt come from unexpected source.
getInfoFromToken(access_token) // return the info loaded in the token
user
methods
constructor(obj)
getAccessToken() // return the user access token
getInfoUser() // return the user info
getRefreshToken() // return the user refresh token
async refreshAccessToken() // refresh the access token
async changePassword(old_password, new_password) // change the user password