Guide · Spring Boot
Google login in Spring Boot
Both paths start the same way: an OAuth client in Google Cloud. The difference is how much of the OAuth2 flow lives in your code and what happens after the user comes back from Google.
Updated
First: the client in Google Cloud
- 1In the Google Cloud Console, create an OAuth client ID credential for a web application.
- 2Register the authorized redirect URI.
- 3Keep the client ID and client secret out of the code.
Path 1: spring-boot-starter-oauth2-client
spring:
security:
oauth2:
client:
registration:
google:
client-id: ${GOOGLE_CLIENT_ID}
client-secret: ${GOOGLE_CLIENT_SECRET}
scope: openid, profile, email@Bean
SecurityFilterChain web(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(a -> a.anyRequest().authenticated())
.oauth2Login(Customizer.withDefaults());
return http.build();
}
// Redirect URI: {baseUrl}/login/oauth2/code/googleThat covers login for an app with a server-side session. For an API with a separate front end, many customers (tenants), or users who also sign in with email and password, you still need to link the Google account to your user, issue your API token, and store all of it.
Path 2: GatekeeperID IAM
- 1In the Console, under Social login, enter the Google client ID and secret.
- 2Copy the redirect URI the Console shows and register it in Google Cloud.
- 3In the backend, start the flow with start and, on your callback, trade the code for the user session with exchange.
# 1. Send the user to Google through GatekeeperID
GET /sdk/integration/v1/social/google/start?redirect_uri=https://app.example.com/auth/google/callback
X-GK-Tenant-ID: <your-tenant>
# 2. Back on your callback, trade the code for the user session
POST /sdk/integration/v1/social/google/exchange
X-GK-Tenant-ID: <your-tenant>A user who signs in with Google is managed in the Console like any other, with the same groups and permissions of the tenant. The Google client secret stays in GatekeeperID, not in the browser.
Both paths side by side
| oauth2-client | GatekeeperID IAM | |
|---|---|---|
| Google client ID and secret | In each application’s application.yml | In the Console, per tenant |
| Token for your API | You design and issue it | JWT issued by GatekeeperID |
| Email and password alongside Google | You build it and link the accounts | Both flows in the same API |
| Many customers (tenants) | Manual configuration | Social login per tenant in the Console |
| Other providers | Configure each one | Microsoft, Apple, and GitHub on the roadmap |
Google login without hand-rolled OAuth2
Request early access and set up Google in the Console in minutes.
Frequently asked questions
- Which social login providers does GatekeeperID support?
- Google today. Microsoft, Apple, and GitHub are on the roadmap.
- Where does the Google client secret live?
- In the GatekeeperID Console, per tenant. It never reaches the browser or your application repository.
- Does it work for Node.js too?
- Yes. The start and exchange flow belongs to the integration API, so it works for any backend, including Node.js with @gatekeeperid/sdk.