Comments (9)
Thank you for pointing to https://jwt.io !
I was able to resolve my claims using that, it looks something like this:
{
"iss": "https://securetoken.google.com/app",
"name": "wildancok",
"id": "60b664d7-9fa6-4c87-b412-b61db20542414",
"aud": "app",
"auth_time": 1504352839,
"user_id": "4ee4daIofZZpjMBdiaEk8PyONAg1",
"sub": "4ee4dsdo9ZZpjMBdiaEk8PyONAg1",
"iat": 1504352839,
"exp": 1504356439,
"email": "[email protected]",
"email_verified": false,
"phone_number": "+1111111111",
"firebase": {
"identities": {
"phone": [
"+1111111111111"
],
"email": [
"[email protected]"
]
},
"sign_in_provider": "custom"
}
}
I only need the id
field. It seems the claims became into one struct containing all the custom fields. So I modified your firebase.Claims
struct into this:
type Claims struct {
Issuer string `json:"iss,omitempty"`
Subject string `json:"sub,omitempty"`
Audience string `json:"aud,omitempty"`
IssuedAt int64 `json:"iat,omitempty"`
ExpiresAt int64 `json:"exp,omitempty"`
UserID string `json:"uid,omitempty"`
ID string `json:"id,omitempty"`
Claims interface{} `json:"claims,omitempty"`
}
Then my tests passed! So how would I go about providing a custom claim struct for token verification? Because whenever I update dependencies using dep
it would revert my changes to this library.
Thank you very much!
from go-firebase-admin.
Okay thank you for the clarification and help. I had different ideas in using the custom token than the official firebase docs you just showed. Maybe I just fork your library just for my use case.
Thank you once again, and sorry for my misunderstanding..
from go-firebase-admin.
Hi,
firebase.auth().currentUser.getIdToken() in client library not include claims in its body.
You can try test your access token in https://jwt.io
from go-firebase-admin.
I was expecting an answer on "how would I go about providing a custom claim struct for token verification? ",
from go-firebase-admin.
Yes!, I'll working on this tonight.
and maybe change type Claims struct {
into type Token struct {
from go-firebase-admin.
Not sure why you need custom claims when verify id token, because firebase access token has its own structure.
Maybe I just add more fields to hold all access token data.
from go-firebase-admin.
hmm.. So what is the point of creating a custom token with additional claims? What is the use case of additional claims?
from go-firebase-admin.
custom token is use for sign in on client (browser) to talk with security rules in firebase database.
see https://firebase.google.com/docs/auth/admin/create-custom-tokens#create_custom_tokens_using_a_third-party_jwt_library
from go-firebase-admin.
IMO, I very sure that when you sign in with custom token, firebase store custom token claims on their server.
btw, you CAN NOT use token from create custom token in verify id token, because It use difference claims structure.
from go-firebase-admin.
Related Issues (19)
- Support for Go Vendoring?
- setup travis
- database: implement Query's Once
- database: implement Query's On
- database: cache `On` data for reuse
- auth: link account
- Rename package to firebase HOT 3
- I can't go get this library undefined: identitytoolkit in identitytoolkit.UserInfo HOT 1
- auth: list user should return raw password and salt
- database: implement Query's Off
- database : implement update / transaction methods on Reference
- auth: Make phoneNumber in UserRecord struct public HOT 1
- Check OpenID reserved claims on additional claims
- Cloud Storage API
- Https request issue in App Engine HOT 2
- cannot use fbFile (type "..projectDir/vendor/google.golang.org/api/option".ClientOption) as type "..ProjectDir/vendor/github.com/acoshift/go-firebase-admin/vendor/google.golang.org/api/option".ClientOption in argument to firebase.InitializeApp HOT 3
- Document AppOptions.DatabaseURL is required HOT 1
- [NEED HELP!] Documentation HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-firebase-admin.