Package com.createsend.util

Examples of com.createsend.util.OAuthAuthenticationDetails


  public OAuthTokenDetails refreshToken() throws CreateSendException {
    OAuthTokenDetails result = null;
    AuthenticationDetails auth = this.jerseyClient
        .getAuthenticationDetails();
    if (auth != null && auth instanceof OAuthAuthenticationDetails) {
      OAuthAuthenticationDetails oauthDetails = (OAuthAuthenticationDetails) auth;
      String body = "grant_type=refresh_token";
      try {
        body += "&refresh_token="
            + URLEncoder.encode(oauthDetails.getRefreshToken(),
                urlEncodingScheme);
      } catch (UnsupportedEncodingException e) {
        body = null;
      }
      JerseyClient oauthClient = new JerseyClientImpl(null);
     
        // TODO: Use a custom error deserialiser in the following post

      result = oauthClient.post(Configuration.Current.getOAuthBaseUri(),
          OAuthTokenDetails.class, body,
          MediaType.APPLICATION_FORM_URLENCODED_TYPE, "token");
      if (result != null && result.access_token != null
          && result.refresh_token != null) {
        AuthenticationDetails newAuthDetails = new OAuthAuthenticationDetails(
            result.access_token, result.refresh_token);
        this.jerseyClient.setAuthenticationDetails(newAuthDetails);
      }
    }
    return result;
View Full Code Here

TOP

Related Classes of com.createsend.util.OAuthAuthenticationDetails

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.