Package org.scribe.exceptions

Examples of org.scribe.exceptions.OAuthException


      if (service.getName().equals(name)) {
        return service;
      }
    }
   
    throw new OAuthException("Service no found by name '"+name+"'.");
  }
View Full Code Here


   
        OAuthRequest _request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
        service.signRequest(accessToken, _request);
        Response _response = _request.send();
        if (_response.getCode() != 200)
          throw new OAuthException("Can query account information.");

        String contentType = _response.getHeader("Content-Type");
    if (contentType == null) contentType = "";
     
    //String charset = "";
    int semicolonPos = contentType.indexOf(';');
     
    if (semicolonPos > 0) {
      String _charset = contentType.substring(semicolonPos + 1).trim();
      if (_charset.startsWith("charset")) {
        //charset =
        _charset.substring(_charset.indexOf('=') + 1);
      }
      contentType = contentType.substring(0, semicolonPos);
    }
     
    Map<String, String> responseAttributes = null;
    String response = _response.getBody();
    if ("application/json".equals(contentType) || (response.startsWith("{") && response.endsWith("}"))) {
      JSONObject jsonResponse = new JSONObject(response);
      if (jsonResponse != null) {
        if (jsonResponse.has("error")) {
          throw new OAuthException("Error getting access token: " + System.getProperty("line.separator") + jsonResponse.toString());
        }
       
        responseAttributes = parseJSONObject(jsonResponse);
      }
    } else if ("text/plain".equals(contentType) || (response.contains("=") && response.contains("&"))) {
      //responseAttributes = OAuthUtil.parseQueryString(response);
    }
   
    if (responseAttributes == null)
          throw new OAuthException("Get response, but no account information.");
     
    String id = responseAttributes.get("id");
   
    String accountName = id + "@google.com";
View Full Code Here

    {
      return new Token(matcher.group(1), "", response);
    }
    else
    {
      throw new OAuthException(
          "Cannot extract an access token. Response was: " + response);
    }
  }
View Full Code Here

TOP

Related Classes of org.scribe.exceptions.OAuthException

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.