Package org.scribe.exceptions

Examples of org.scribe.exceptions.OAuthException


                  String token = OAuthEncoder.decode(matcher.group(1));
                  return new Token(token, "", response);
                }
                else
                {
                  throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null);
                }
            }
        };
    }
View Full Code Here


            final String queryString = new URL(this.url).getQuery();
            result.addQuerystring(queryString);
            result.addAll(this.querystringParams);
            return result;
        } catch (final MalformedURLException mue) {
            throw new OAuthException("Malformed URL", mue);
        }
    }
View Full Code Here

     */
    public String getBodyContents() {
        try {
            return new String(getByteBodyContents(), getCharset());
        } catch (final UnsupportedEncodingException uee) {
            throw new OAuthException("Unsupported Charset: " + this.charset, uee);
        }
    }
View Full Code Here

            return this.bytePayload;
        final String body = (this.payload != null) ? this.payload : this.bodyParams.asFormUrlEncodedString();
        try {
            return body.getBytes(getCharset());
        } catch (final UnsupportedEncodingException uee) {
            throw new OAuthException("Unsupported Charset: " + getCharset(), uee);
        }
    }
View Full Code Here

    protected String getProfileUrl(final Token accessToken) {
        if (accessToken instanceof OrcidToken) {
            return String.format("https://api.orcid.org/v1.1/%s/orcid-profile",
                    ((OrcidToken) accessToken).getOrcid());
        } else {
            throw new OAuthException("Token in getProfileUrl is not an OrcidToken");
        }
    }
View Full Code Here

        Preconditions.checkEmptyString(response, "Cannot extract a token from a null or empty String");
        final Matcher matcher = this.accessTokenPattern.matcher(response);
        if (matcher.find()) {
            return new Token(matcher.group(1), "", response);
        } else {
            throw new OAuthException("Cannot extract an acces token. Response was: " + response);
        }
    }
View Full Code Here

            final String accessToken = matcher.group(1);
            matcher = this.orcidTokenPattern.matcher(response);
            if (matcher.find() && matcher.groupCount() > 0) {
                return new OrcidToken(accessToken, "", matcher.group(1), response);
            } else {
                throw new OAuthException("Cannot extract orcid. Response was: " + response);
            }
        } else {
            throw new OAuthException("Cannot extract an access token. Response was: " + response);
        }
    }
View Full Code Here

        Preconditions.checkEmptyString(response, "Cannot extract a token from a null or empty String");
        final Matcher matcher = this.accessTokenPattern.matcher(response);
        if (matcher.find()) {
            return new Token(matcher.group(1), "", response);
        } else {
            throw new OAuthException("Cannot extract an acces token. Response was: " + response);
        }
    }
View Full Code Here

        Preconditions.checkEmptyString(response, "Cannot extract a token from a null or empty String");
        Matcher matcher = accessTokenPattern.matcher(response);
        if (matcher.find()) {
            return new Token(matcher.group(1), "", response);
        } else {
            throw new OAuthException("Cannot extract an acces token. Response was: " + response);
        }
    }
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 + "@facebook.com";
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.