简体   繁体   中英

Authentificate user with external oAuth2 provider, java spring

I am currently playing around with java framework Spring (new with this), trying to build stateless REST API for mobile devices with oAuth2 authorization. In general, i want to implement the folowing steps:

  • User visit login url, from there he will be redirected by server to oAuth provider to authentificate there
  • Social provider return user with code on redirect url, which i fill in previous request as GET parameter
  • In redirect url i catch the code, exchange it for data from social provider, and if data is valid, i find user in my database, associated with this data (by social id, for example) and generate for user my token and return it.
  • On all requests later client give me this token in HTTP header and i find user by this token (already implements with spring security filters)

Thats all, all i need from social provider it is to authentificate user, but i didnt find easy examples for solving this problem - everywhere huge libs with tons of abstraction, trying to build more complex security layer for me then i want to.

Can someone give me code examples or links to explore with easy solutions of this easy problem with spring tools, preferable in java config? (getting user data from external oAuth2 provider)

因此,几天后,我发现了用于oAuth请求的惊人的lib (称为scribe),它可以用几行代码来完成我想要的所有工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM