Guest User

Untitled

a guest
Feb 16th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import auth0 from 'auth0-js';
  2. export default class Auth {
  3. constructor({domain, clientID, audience})
  4. {
  5. this.auth0 = new auth0.WebAuth({
  6. domain,
  7. clientID,
  8. redirectUri: `${window.location.origin}/authenticate`,
  9. audience,
  10. responseType: 'token id_token',
  11. scope: 'openid profile email',
  12. });
  13. }
  14. login() {
  15. this.auth0.authorize();
  16. }
  17. parseTokens() {
  18. return new Promise((resolve, reject) => this.auth0.parseHash((err,
  19. result) => {
  20. if (err) {
  21. reject(err);
  22. } else {
  23. resolve({...result, expiresAt: (result.expiresIn * 1000) + new
  24. Date().getTime()});
  25. }
  26. }
  27. ));
  28. }
  29. }
Add Comment
Please, Sign In to add comment