Thursday 15 April 2010

oauth 2.0 - How to get authenticated token after redirecting user -


I was getting when I say an error message when I service.getRequestToken (authentication) through a request token was obtained to try , I'm not really allowed to do so, and instead users should use service.getAuthorizationUrl () to redirect. The problem is, I do not know what I have to do next to do service.getAccessToken () I do not have a tokens, and I do not know how to get the proper verification.

  • How do I get the necessary verification to obtain an essential token?
  • How do I get the required request token, because I service.getRequestToken () ?

    Even I still have the code:

      import java.awt.Desktop; Import java.net.URI; Import org.scribe.model. *; Import org.scribe.oauth.OAuthService; Public Class Haloboks {public static Whaid Main (string [] AGR) is irritating exception (Boksoayuth 2 API box = new Boksoath 2 API ()); OAuthConfig config = new OAuthConfig (/ * [...] * /, // Client ID / * [...] * / // client secret "https: // Sthaniyhost 4000", // callback null, null , // signature type, scope System.out // debug stream); OAuthService service = box.createService (config); . Desktop.getDesktop () Browse (URI.create (service.getAuthorizationUrl (zero))); // === Now what do I do? === Validator v = new validator (/ * ??? * /); Token access token = service.getAccessToken (blank, V); }}   

    I got the online box online BoxOAuth2API if the problem is with this, where is an API class that works?

      public class BoxOAuth2API default Api20 {//http://developers.box.com/docs/ private static final String AUTHORIZE_URL = "https://www.box.com/api/oauth2/ Authorize? Client_id =% s & redirect_uri =% s & response_type = code "; Private static final string SCOPED_AUTHORIZE_URL = AUTHORIZE_URL + "and scope =% s"; Obtain override public verb AccessTokenVerb () {return Verb.POST; } @ Override Public AccessTrackActractGetAccessTokenExtractor () Return to {New JasonTokEnctactor ()); } @ Override public string receivedAxtocon endpoint () {"https://www.box.com/api/oauth2/token?grant_type=authorization_code"; } @Override public string getAuthorizationUrl (OAuthConfig config) {// if the scope of the present enclosed (config.hasScope ()) {return String.Format (SCOPED_AUTHORIZE_URL, config.getApiKey (), OAuthEncoder.encode (config.getCallback ()) , OAuthEncoder.encode (config.getScope ())); } Else {return String.format (AUTHORIZE_URL, config.getApiKey), OAuthEncoder.encode (config.getCallback ())); }}}    

    "itemprop =" text ">

    In order for you to get a callback, if you have enough You can get the HTTP request received from the control box of your machine to run the listener process. The box will call you at http at a local host address only. You must use https for any other callback from the local host address.

    The box SDK manages the OAUIT stuff for you

      import org.scribe.model. * Should not be required; Import org.scribe.oauth.OAuthService;   

    You also have to configure your box app to point to whatever address you want to call out for it. I firmly recommend, that since the bus will work on most computers, to start with the local host, and you do not need to install the SSL certificate. I have updated the instructions for example now. Hope this helps a little bit.

No comments:

Post a Comment