[英]Java scribe client with OAuth 2 Resource Owner Password Credentials
I am building a mobile app that uses the Authorization Grant type "Resource Owner Password Credentials" 我正在构建一个使用授权授予类型“资源所有者密码凭证”的移动应用程序
Tested the code in Ruby with the "oauth2" gem and it works fine 使用“ 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 code 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();
How can I provide the username and password in Scribe (or with other library preferably compatible with Android)? 如何在Scribe(或与Android最好兼容的其他库)中提供用户名和密码?
Right now I cannot find a way to do this with Scribe extending "DefaultApi20". 现在,我找不到使用Scribe扩展“ DefaultApi20”的方法。
I understand now that this is just a POST request 我现在知道这只是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.