Skip to content

Latest commit

 

History

History
30 lines (26 loc) · 599 Bytes

tokens.md

File metadata and controls

30 lines (26 loc) · 599 Bytes

Tutorial: JWT Tokens

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

Source
function clientLogic() {
  firebase.auth().currentUser.getIdToken().then(function(token) {
    // make request to firebase service using token
    console.log(token);
  });
}
Test
mocksdk.auth().autoFlush();

// create user
mocksdk.auth().createUser({
  uid: '123',
  email: 'test@test.com',
  password: 'abc123'
}).then(function(user) {
  // set user as current user for client logic
  mocksdk.auth().changeAuthState(user);
});

clientLogic();
// token has been logged