Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/main/java/com/google/firebase/auth/FirebaseAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ public class FirebaseAuth {
private final Object lock;

private FirebaseAuth(FirebaseApp firebaseApp) {
this(firebaseApp, FirebaseTokenVerifier.DEFAULT_KEY_MANAGER, Clock.SYSTEM);
this(firebaseApp,
FirebaseTokenVerifier.buildGooglePublicKeysManager(
firebaseApp.getOptions().getHttpTransport()),
Clock.SYSTEM);
}

/**
Expand Down Expand Up @@ -210,12 +213,14 @@ private Task<FirebaseToken> verifyIdToken(final String token, final boolean chec
return call(new Callable<FirebaseToken>() {
@Override
public FirebaseToken call() throws Exception {

FirebaseTokenVerifier firebaseTokenVerifier =
new FirebaseTokenVerifier.Builder()
.setProjectId(projectId)
.setPublicKeysManager(googlePublicKeysManager)
.setClock(clock)
.build();

FirebaseToken firebaseToken = FirebaseToken.parse(jsonFactory, token);

// This will throw a FirebaseAuthException with details on how the token is invalid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.api.client.auth.openidconnect.IdToken.Payload;
import com.google.api.client.auth.openidconnect.IdTokenVerifier;
import com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.client.json.webtoken.JsonWebSignature.Header;
Expand Down Expand Up @@ -183,6 +184,13 @@ public String getProjectId() {
return projectId;
}

public static GooglePublicKeysManager buildGooglePublicKeysManager(HttpTransport transport) {
return new GooglePublicKeysManager.Builder(transport, new GsonFactory())
.setClock(Clock.SYSTEM)
.setPublicCertsEncodedUrl(FirebaseTokenVerifier.CLIENT_CERT_URL)
.build();
}

/**
* Builder for {@link FirebaseTokenVerifier}.
*/
Expand Down