开发者

Create "Provider" in Java with Oauth library?

开发者 https://www.devze.com 2023-02-12 05:38 出处:网络
I downloaded the examples (https://code.google.com/p/oauth/) compiled and loaded the provider and consumer WAR files to Apache Tomcat.

I downloaded the examples (https://code.google.com/p/oauth/) compiled and loaded the provider and consumer WAR files to Apache Tomcat.

I configured provider.properties with: Consumer_key=mysecret (i'm not sure if i can set this as key) Consumer_key.description=Get a GPS position Consumer_key.callbackURL=http://localhost:8081/oauthC/OAuth/Callback

consumer.properties with: sample.serviceProvider.baseURL: http://localhost:8081/oauthP/ sample.serviceProvider.requestTokenURL: request_token sample.serviceProvider.userAuthorizationURL: authorize sample.serviceProvider.accessTokenURL: access_token sample.consumerKey: mysecret sample.consumerSecret: mysecret (i'm quite confused what should i set in this attr)

and start the server. I accessed http://localhost:8081/oauthC/ (consumer site) go to sample and it returned this:

OAuthProblemException: oauth_problem: token_rejected

HTTP request: GET /oauthP/request_token?oauth_callback=http%3A%2F%2Flocalhost%3A8081%2FoauthC%2FOAuth%2FCallback%3Fconsumer%3Dsample%26returnTo%3D%252FoauthC%252FSampleProvider&oauth_consumer_key=mysecret&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1298329818&oauth_nonce=13474056411695&oauth_version=1.0&oauth_signature=JwuEr0jprO8G3bKRhXHdqpeuuxI%3D User-Agent: Jakarta Commons-HttpClient/3.1 Host: localhost:8081

HTTP status: 401

HTTP response: HTTP/1.1 401 Unauthorized Server: Apache-Coyote/1.1 WWW-Authenticate: OAuth realm="http%3A%2F%2Flocalhost.localdomain", oauth_problem="token_rejected" Content-Type: application/x-www-form-urlencoded;charset=UTF-8 Content-Length: 28 Date: Mon, 21 Feb 2011 23:10:18 GMT oauth_problem=token_rejected

oauth_signature base string: GET&http%3A%2F%2Flocalhost%3A8081%2FoauthP%2Frequest_token&oauth_callback%3Dhttp%253A%252F%252Flocalhost%253A8081%252FoauthC%252FOAuth%252FCallback%253Fconsumer%253Dsample%2526returnTo%253D%25252FoauthC%25252FSampleProvider%26oauth_consumer_key%3Dmysecret%26oauth_nonce%3D13474056411695%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1298329818%26oauth_version开发者_开发知识库%3D1.0

URL: http://localhost:8081/oauthP/request_token?oauth_callback=http%3A%2F%2Flocalhost%3A8081%2FoauthC%2FOAuth%2FCallback%3Fconsumer%3Dsample%26returnTo%3D%252FoauthC%252FSampleProvider&oauth_consumer_key=mysecret&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1298329818&oauth_nonce=13474056411695&oauth_version=1.0&oauth_signature=JwuEr0jprO8G3bKRhXHdqpeuuxI%3D

I'm stuck at this. Anyone can give an advice ? or show me documentation for this lib ? i can't find anything...

thx for ur time

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号