English 中文(简体)
如何在编录中使用访问标记获得刷新标记
原标题:How to get refresh token using access token in scribe
  • 时间:2012-05-24 07:57:56
  •  标签:
  • oauth
  • scribe

i have got access token now i want to have refresh token so that i can refresh my access token whenever needed. i used fallowing code but it returned error response

  **OAuthRequest request = new OAuthRequest(Verb.POST, "https://accounts.google.com/o/oauth2/token");
    request.addBodyParameter("grant_type", "refresh_token");
    request.addBodyParameter("refresh_token", "accesstoken string"); 

    request.send();**

有什么想法 如何得到更新的标志?

问题回答

您可以使用以下代码做到这一点

OAuthRequest request = new OAuthRequest(Verb.POST, "https://accounts.google.com/o/oauth2/token");
    request.addBodyParameter("grant_type", "refresh_token");
    request.addBodyParameter("refresh_token", accessToken.getToken()); // were accessToken is the Token object you want to refresh.
    request.addBodyParameter("client_id", your clientID);
    request.addBodyParameter("client_secret", your clientSecret);
    Response response = request.send();

A refresh token is obtained in offline scenarios as mentioned in https://developers.google.com/accounts/docs/OAuth2WebServer#offline Make sure access_type is offline

事实上,Scribe并没有让你得到一个刷新标记。我不得不定制它来让它成为可能,我这样做是因为我没有选择,甚至图书馆的主人(Jerome Leleu)也没有提供维修,他正在用一个叫做Pac4j的新版本工作。





相关问题
Cannot get Twitter-OAuth-iPhone to work

demo works as expected, no problems. But now I m trying to integrate it into my project. I use no xib-s, code only: OAuthTwitterDemoViewController *vc = [[OAuthTwitterDemoViewController alloc] init]; ...

Library for OAuth Provider (Java) [closed]

I m looking for a Java library that helps me building an OAuth Provider. I must be able to receive OAuth signed requests and determine whether they are valid or not (checking the signature, timestamp ...

twitter status update using tweetsharp oauth preview 17

I am trying to update the status using tweetsharp oauth preview 17. Please let me know how ?. I tried this code var msg = FluentTwitter.CreateRequest() .AuthenticateWith(_consumerKey, ...

How to keep RoleProvider from overriding custom roles?

I have an custom role provider that gets the roles a user belongs to from a database. I also have a custom authentication module registered in my web.config s httpModules which sniffs incoming HTTP ...

How to test the twitter API locally?

I m trying to write a web application that would use Twitter via OAuth. I run my local server as localhost , so I need the callback URL to be something like http://localhost/something/twitter.do ...

o和使用

i 一旦从山角到用户接触,我会感到非常混乱,

oauth problem( app engine)

i am trying to pull user s documents data from google docs using oauth, but i cannot understand how to do it - what s the purpose of oauth_verifier - how to get the access token secret? - if i try to ...

热门标签