File tree Expand file tree Collapse file tree 4 files changed +40
-0
lines changed
firebase-auth-rest/core/src/main/java/com/anotherdev/firebase/auth Expand file tree Collapse file tree 4 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ public interface FirebaseAuth {
4545 @ CheckReturnValue
4646 Single <SignInResponse > signInWithCredential (@ NonNull IdpAuthCredential credential );
4747
48+ @ NonNull
49+ @ CheckReturnValue
50+ Single <SignInResponse > signInWithCustomToken (@ NonNull String customToken );
51+
4852 @ NonNull
4953 @ CheckReturnValue
5054 Single <SignInResponse > linkWithCredential (@ NonNull FirebaseUser user , @ NonNull IdpAuthCredential credential );
Original file line number Diff line number Diff line change 1515import com .anotherdev .firebase .auth .rest .api .model .ExchangeTokenRequest ;
1616import com .anotherdev .firebase .auth .rest .api .model .ImmutableSignInWithIdpRequest ;
1717import com .anotherdev .firebase .auth .rest .api .model .SignInAnonymouslyRequest ;
18+ import com .anotherdev .firebase .auth .rest .api .model .SignInWithCustomTokenRequest ;
1819import com .anotherdev .firebase .auth .rest .api .model .SignInWithEmailPasswordRequest ;
1920import com .anotherdev .firebase .auth .rest .api .model .SignInWithIdpRequest ;
2021import com .anotherdev .firebase .auth .util .IdTokenParser ;
@@ -124,6 +125,17 @@ public Single<SignInResponse> signInWithCredential(@NonNull IdpAuthCredential cr
124125 return performSignInWithCredential (builder , credential );
125126 }
126127
128+ @ NonNull
129+ @ Override
130+ public Single <SignInResponse > signInWithCustomToken (@ NonNull String customToken ) {
131+ SignInWithCustomTokenRequest request = SignInWithCustomTokenRequest .builder ()
132+ .customToken (customToken )
133+ .build ();
134+ return RestAuthApi .auth ()
135+ .signInWithCustomToken (request )
136+ .map (this ::saveCurrentUser );
137+ }
138+
127139 @ NonNull
128140 @ Override
129141 public Single <SignInResponse > linkWithCredential (@ NonNull FirebaseUser user , @ NonNull IdpAuthCredential credential ) {
Original file line number Diff line number Diff line change 44import com .anotherdev .firebase .auth .UserProfileChangeRequest ;
55import com .anotherdev .firebase .auth .rest .api .model .IdTokenRequest ;
66import com .anotherdev .firebase .auth .rest .api .model .SignInRequest ;
7+ import com .anotherdev .firebase .auth .rest .api .model .SignInWithCustomTokenRequest ;
78import com .anotherdev .firebase .auth .rest .api .model .SignInWithEmailPasswordRequest ;
89import com .anotherdev .firebase .auth .rest .api .model .SignInWithIdpRequest ;
910import com .anotherdev .firebase .auth .rest .api .model .UserPasswordChangeRequest ;
@@ -31,6 +32,9 @@ public interface IdentityToolkitApi {
3132 @ POST ("v1/accounts:signInWithIdp" )
3233 Single <SignInResponse > signInWithCredential (@ Body SignInWithIdpRequest request );
3334
35+ @ POST ("v1/accounts:signInWithCustomToken" )
36+ Single <SignInResponse > signInWithCustomToken (@ Body SignInWithCustomTokenRequest request );
37+
3438 @ POST ("v1/accounts:lookup" )
3539 Single <JsonObject > getAccounts (@ Body IdTokenRequest request );
3640
Original file line number Diff line number Diff line change 1+ package com .anotherdev .firebase .auth .rest .api .model ;
2+
3+ import com .google .gson .annotations .SerializedName ;
4+
5+ import org .immutables .gson .Gson ;
6+ import org .immutables .value .Value ;
7+
8+ @ Value .Immutable
9+ @ Value .Style (strictBuilder = true )
10+ @ Gson .TypeAdapters
11+ public interface SignInWithCustomTokenRequest extends SignInRequest {
12+
13+ @ SerializedName ("token" )
14+ String getCustomToken ();
15+
16+
17+ static ImmutableSignInWithCustomTokenRequest .Builder builder () {
18+ return ImmutableSignInWithCustomTokenRequest .builder ();
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments