繁体   English   中英

具有OAuth 2资源所有者密码凭证的Java scribe客户端

[英]Java scribe client with OAuth 2 Resource Owner Password Credentials

我正在构建一个使用授权授予类型“资源所有者密码凭证”的移动应用程序

使用“ oauth2” gem在Ruby中测试了代码,并且工作正常

client = OAuth2::Client.new('the_client_id', 'the_client_secret', :site => "http://example.com")
access_token = client.password.get_token('user@example.com', 'sekret')
puts access_token.token

Java代码

OAuthService service = new ServiceBuilder()
        .provider(MyApi.class)
        .apiKey("the_client_id")
        .apiSecret("the_client_secret")
        .debug()
        .build();
// the next step should provide ('user@example.com', 'sekret')
// because I am using "Resource Owner Password Credentials"
// http://tools.ietf.org/html/draft-ietf-oauth-v2-31#page-53
Token requestToken = service.getRequestToken(); 

如何在Scribe(或与Android最好兼容的其他库)中提供用户名和密码?

现在,我找不到使用Scribe扩展“ DefaultApi20”的方法。

我现在知道这只是POST请求

curl -i http://localhost:3000/oauth/token \
  -F grant_type=password \
  -F client_id=the_client_id \
  -F client_secret=the_client_secret \
  -F username=user@example.com \
  -F password=sekret

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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