For generation of custom token is used io.jsonwebtoken:jjwt:0.6.0
Map<String, Object> claims = new LinkedHashMap<>();
claims.put("iss", "");
claims.put("sub", UUID.randomUUID().toString());
claims.put("aud", "firebase_email_address");
claims.put("uid", UUID.randomUUID().toString());
Optional<String> customToken = Optional.of(Jwts.builder()
.setClaims(claims)
.signWith(SignatureAlgorithm.RS256, service_account_private_key)
.compact());
Description in documentation:
If your backend is in a language that doesn't have an official Firebase Admin SDK, you can still manually create custom tokens. Find a third-party JWT library for your language [enter link description here][1].
But when try client to log in with this token:
firebaseAuth.signInWithCustomToken(response.data.token).then(function (success) {
console.log('Login Success!', success);
}, function (error) {
console.error('Error ' , error);
});
this error is received:
Error in console
Source: AngularJS
from Angular Questions https://angularquestions.com/2017/10/05/firebase-custom-auth-error-used-custom-token-to-login/
via @lzomedia #developer #freelance #web #lzomedia.com
No comments:
Post a Comment