Skip to content

Latest commit

 

History

History
31 lines (27 loc) · 587 Bytes

tokens.md

File metadata and controls

31 lines (27 loc) · 587 Bytes

Tutorial: JWT Tokens

Mock JWT tokens used to identify the user to a Firebase service.

Source
function serverLogic(token) {
  firebase.auth().verifyIdToken(token).then(function(user) {
    // do something with the user
    console.log(user.uid);
  });
}
Test
mocksdk.auth().autoFlush();

// create user
mocksdk.auth().createUser({
  uid: '123',
  email: '[email protected]',
  password 'abc123'
});

mocksdk.auth().getUser('123').then(function(user) {
  user.getIdToken().then(function(token) {
    serverLogic(token);
    // uid has been logged
  });
});