r/SpringBoot • • Jul 30 '25

Discussion Just finished implementing GitHub OAuth2 login with Spring Boot + Angular

Hey everyone,

I just wrapped up GitHub OAuth2 login for my full-stack app (Spring Boot backend + Angular frontend) and wanted to share the implementation. It took a bit of trial and error, especially around token handling and integrating the frontend redirect flow.

🛠️ Stack & Highlights:

  • Backend: Spring Boot 3, Spring Security, OAuth2 Client

  • Frontend: Angular 17

  • Flow:

    • Spring Boot handles the GitHub OAuth2 callback and generates a JWT

    • JWT is sent via redirect to Angular (/oauth2/success?token=...)

    • Angular grabs the token from the URL, stores it, and uses it for API requests

  • Security: Stateless JWT-based authentication (no session storage)

  • Edge Case Handled: Linking GitHub OAuth2 login with existing users in the DB who previously signed up using email/password

If you're curious or have suggestions, here's the pull request:
🔗 https://github.com/n1netails/n1netails/pull/133

Would love any feedback on code structure, security, or overall design. Thanks!

35 Upvotes

Duplicates