【发布时间】:2014-09-15 20:07:21
【问题描述】:
我想将 Oauth2 和 Spring-security 与 rest web 服务一起使用。我是新手,我正在尝试在一些网站的帮助下创建配置。不过,我显然不明白 oauth 验证休息服务的方式和流程是什么。我正在使用最新的依赖项Click on the link for see my configurations。我正在使用数据库来存储客户信息和令牌。当我尝试访问令牌时,使用带有发布请求和发布正文的以下 url:
http://localhost:8080/empirecl-api/oauth/token
grant_type=password&username=a@a.com&password=password&client_id=my-client-with-secret&client_secret=ak_secret
将出现基本身份验证弹出框。我正在使用 chrome rest postman 客户端。我的数据库中有用户表,用于存储用户名和密码,当我输入username 和password 时,身份验证失败,如果我使用我的client_id 和client_secret 作为username 和@ 987654328@,认证失败。当我在json 之后取消基本身份验证的弹出时返回:
{
"error": "unauthorized",
"error_description": "No client with requested id: a@a.com"
}
我不知道会发生什么。
当我尝试使用 get reqquest 访问以下网址时:
http://localhost:8080/empirecl-api/oauth/authorize?grant_type=password&username=a@a.com&password=password
以下error 将返回:
{
"error": {
"error": "invalid_client",
"error_description": "Bad client credentials"
}
}
当我在 Eclipse 的控制台中检查错误时,会显示以下错误:
AuthorizationEndpoint:436 - Handling ClientRegistrationException error: No client with requested id: null
我如何解决这个问题以及如何将 Oauth 与我的 rest api 一起使用。我还想用 Oauth 保护我所有的 url。
【问题讨论】:
标签: exception spring-security oauth-2.0 basic-authentication