Skip to content

Demonstrates how to write secure Web Applications using Google Oauth2 on client side and securing protected resources with JWT based token

License

Notifications You must be signed in to change notification settings

pavlo-kravchenko/google-oauth2-jwt-secure-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Securing backend APIs when developing Client side web applications Build Status

Blog link

Medium

How to run

clone the repository

git clone [email protected]:hhimanshu/google-oauth2-jwt-secure-api.git

compile, test, create package

mvn clean package

start the server

mvn spring-boot:run
  • Go to http://localhost:8080

  • Sign In with Google

  • Open Developer Tools and after login you your see an object structure under path current user > Ab > Zi

  • locate id_token and copy the value

Authenticate with your application APIs

curl -v -X POST -H "Content-Type: application/json" -H "X-ID-TOKEN: <place your id_token here>" -d'{}' http://localhost:8080/login

If the requests succeeds, you would see token coming from your app in Authorization header similar to following

Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJteVVuaXF1ZVVzZXIiLCJleHAiOjE0OTUwMDA3NjV9.B4Ax_BIkrW044rwVnN-qvLcT9r0JzP4VCECjExp3yTFqv4STNmEiG4LNBHU-BXjAOSgt9xuLV7LhVXPKLYApbQ

You can now use this token to further communicate the server.

About

Demonstrates how to write secure Web Applications using Google Oauth2 on client side and securing protected resources with JWT based token

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 57.9%
  • Shell 19.6%
  • Batchfile 15.1%
  • HTML 7.4%