File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ // Initialize the Admin app with the default appication credentials
2+ // [START initialize_sdk_with_default_config]
3+ admin . initializeApp ( ) ;
4+ // [END initialize_sdk_with_default_config]
5+
6+ // Initialize the Admin app by providing a service accoune key
7+ // [START initialize_sdk_with_service_account_id]
8+ admin . initializeApp ( {
9+ serviceAccountId : 'my-client-id@my-project-id.iam.gserviceaccount.com' ,
10+ } ) ;
11+ // [END initialize_sdk_with_service_account_id]
12+
13+ // [START custom_token]
14+ var uid = "some-uid" ;
15+
16+ admin . auth ( ) . createCustomToken ( uid )
17+ . then ( function ( customToken ) {
18+ // Send token back to client
19+ } )
20+ . catch ( function ( error ) {
21+ console . log ( "Error creating custom token:" , error ) ;
22+ } ) ;
23+ // [END custom_token]
24+
25+ // [START custom_token_with_claims]
26+ var uid = "some-uid" ;
27+ var additionalClaims = {
28+ premiumAccount : true
29+ } ;
30+
31+ admin . auth ( ) . createCustomToken ( uid , additionalClaims )
32+ . then ( function ( customToken ) {
33+ // Send token back to client
34+ } )
35+ . catch ( function ( error ) {
36+ console . log ( "Error creating custom token:" , error ) ;
37+ } ) ;
38+ // [END custom_token_with_claims]
You can’t perform that action at this time.
0 commit comments