使用 Java 配置的 Spring OAuth2 的最简单示例是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30088677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the simplest example of Spring OAuth2 with Java configuration?
提问by Dimitris
I have recently built a REST API in Spring which I am consuming with a .Net C# client. At the moment there is no security so I would like to implement OAuth2. I am going to be the only user of my REST API so I don't need something complicated. Is there a simple example somewhere of Spring Security OAuth2 with java configuration? I looked in many places but either the examples use xml or they are too old and out of date or simply too complicated for what I need. I would appreciate any pointers with this.
我最近在 Spring 中构建了一个 REST API,我正在使用 .Net C# 客户端。目前没有安全性,所以我想实现 OAuth2。我将成为我的 REST API 的唯一用户,所以我不需要复杂的东西。是否有带有 java 配置的 Spring Security OAuth2 某处的简单示例?我查看了很多地方,但这些示例要么使用 xml,要么它们太旧和过时,或者对于我需要的东西来说太复杂了。我将不胜感激。
By the way I looked at the Sparklr tutorial and github repo but they seem too complicated for what I need.
顺便说一下,我查看了 Sparklr 教程和 github 存储库,但它们对于我所需要的来说似乎太复杂了。
采纳答案by nKognito
回答by Matthias
You see the examples of the spring project?
你看到spring项目的例子了吗?
https://github.com/spring-projects/spring-security-oauth/tree/master/samples
https://github.com/spring-projects/spring-security-oauth/tree/master/samples
回答by santc mc
Below project provided a good example, in both server/client side.
下面的项目提供了一个很好的例子,在服务器/客户端。
https://github.com/bassemZohdy/Spring_REST_OAuth_Demo
https://github.com/bassemZohdy/Spring_REST_OAuth_Demo
Hope that helps.
希望有帮助。