Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit adf2493

Browse files
committed
snippets
1 parent 47f5723 commit adf2493

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

auth/src/main/java/com/google/firebase/quickstart/AuthSnippets.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,18 @@ public static void verifyIdToken(String idToken) throws InterruptedException, Ex
210210
public static void verifyIdTokenCheckRevoked(String idToken) throws InterruptedException, ExecutionException {
211211
// [START verify_id_token_check_revoked]
212212
// Note the second parameter, checkRevoked set to true.
213+
try {
213214
FirebaseToken decodedToken = FirebaseAuth.getInstance().verifyIdTokenAsync(idToken, true).get();
215+
}
216+
catch (FirebaseAuthException e) {
217+
if (FirebaseUserManager.ID_TOKEN_REVOKED_ERROR == e.getErrorCode()) {
218+
// Token is valid but has been revoked.
219+
// When this occurs, inform the user to reauthenticate or signOut() the user.
220+
}
221+
222+
223+
}
224+
214225
String uid = decodedToken.getUid();
215226
// [END verify_id_token_check_revoked]
216227
System.out.println("Decoded ID token from user: " + uid);
@@ -221,6 +232,7 @@ public static void revokeIdTokens(String idToken) throws InterruptedException, E
221232
// idToken comes from the client app (shown above)
222233
FirebaseToken decodedToken = FirebaseAuth.getInstance().verifyIdTokenAsync(idToken).get();
223234
String uid = decodedToken.getUid();
235+
224236
// [END revoke_tokens]
225237
System.out.println("Decoded ID token from user: " + uid);
226238
}

0 commit comments

Comments
 (0)