-
Notifications
You must be signed in to change notification settings - Fork 147
Align the comments in the check revoked (verify id token) #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7c795b2
Align comments
avishalom 6bcc0a6
Merge branch 'master' into align2
avishalom a9abc53
import
avishalom 0efdebc
change immutable map builder
avishalom 312e24a
imports
avishalom b810459
.
avishalom 44f788b
.
avishalom 152bd7b
.
avishalom d21b915
async
avishalom 92a59a8
.
avishalom 0463d2a
immutable
avishalom f46bbef
catch
avishalom 3c3061c
Align comments
avishalom 3834676
PR fixes
avishalom 6ba99d9
PR fixes
avishalom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,18 @@ | ||
| package com.google.firebase.quickstart; | ||
|
|
||
| import com.google.auth.oauth2.GoogleCredentials; | ||
| import com.google.common.collect.ImmutableMap; | ||
| import com.google.firebase.FirebaseApp; | ||
| import com.google.firebase.FirebaseOptions; | ||
| import com.google.firebase.auth.ExportedUserRecord; | ||
| import com.google.firebase.auth.FirebaseAuth; | ||
| import com.google.firebase.auth.FirebaseAuthException; | ||
| import com.google.firebase.auth.FirebaseToken; | ||
| import com.google.firebase.auth.ListUsersPage; | ||
| import com.google.firebase.auth.UserRecord; | ||
| import com.google.firebase.auth.UserRecord.CreateRequest; | ||
| import com.google.firebase.auth.UserRecord.UpdateRequest; | ||
| import com.google.firebase.database.*; | ||
| import java.io.FileInputStream; | ||
| import java.io.IOException; | ||
| import java.util.HashMap; | ||
|
|
@@ -216,13 +219,13 @@ public static void verifyIdTokenCheckRevoked(String idToken) throws InterruptedE | |
| FirebaseToken decodedToken = FirebaseAuth.getInstance().verifyIdTokenAsync(idToken, checkRevoked).get(); | ||
| // Token is valid and not revoked. | ||
| String uid = decodedToken.getUid(); | ||
| } | ||
| catch (FirebaseAuthException e) { | ||
| if ("id-token-revoked".equals(e.getErrorCode())) { | ||
| // Token is valid but has been revoked. | ||
| // When this occurs, inform the user to reauthenticate or signOut() the user. | ||
| } else { | ||
| // Token is invalid. | ||
| } catch (ExecutionException e) { | ||
| if (e.getCause() instanceof FirebaseAuthException) { | ||
| if ( ((FirebaseAuthException) e.getCause()).getErrorCode().equals("id-token-revoked")) { | ||
| // Token has been revoked. Inform the user to reauthenticate or signOut() the user. | ||
| } else { | ||
| // Token is invalid. | ||
| } | ||
| } | ||
| } | ||
| // [END verify_id_token_check_revoked] | ||
|
|
@@ -231,7 +234,7 @@ public static void verifyIdTokenCheckRevoked(String idToken) throws InterruptedE | |
| public static void revokeIdTokens(String idToken) throws InterruptedException, ExecutionException { | ||
| String uid="someUid"; | ||
| // [START revoke_tokens] | ||
| FirebaseToken decodedToken = FirebaseAuth.getInstance().revokeRefreshTokens(uid).get(); | ||
| FirebaseAuth.getInstance().revokeRefreshTokensAsync(uid).get(); | ||
| UserRecord user = FirebaseAuth.getInstance().getUserAsync(uid).get(); | ||
| // Convert to seconds as the auth_time in the token claims is in seconds too. | ||
| long revocationSecond = user.getTokensValidAfterTimestamp() / 1000; | ||
|
|
@@ -240,7 +243,7 @@ public static void revokeIdTokens(String idToken) throws InterruptedException, E | |
|
|
||
| // [START save_revocation_in_db] | ||
| DatabaseReference ref = FirebaseDatabase.getInstance().getReference("metadata/" + uid); | ||
| ref.setValueAsync(MapBuilder.of("revokeTime", revocationSecond)).get(); | ||
| ref.setValueAsync(ImmutableMap.<String, Object>of("revokeTime", revocationSecond)).get(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just use HashMap here. ImmutableMap is a guava type and I don't think we want it to appear in snippets. |
||
| // [END save_revocation_in_db] | ||
|
|
||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Break into a couple of lines: