public OAuthProtocolException(OAuthMessage reply) { String problem = reply.getParameter(OAuthProblemException.OAUTH_PROBLEM); if (problem == null) { throw new ArgumentException( "No problem reported for OAuthProtocolException"); } problemCode = problem; if (fatalProblems.Contains(problem)) { startFromScratch = true; canRetry = false; canExtend = false; } else if (temporaryProblems.Contains(problem)) { startFromScratch = false; canRetry = false; canExtend = false; } else if (extensionProblems.Contains(problem)) { startFromScratch = false; canRetry = true; canExtend = true; } else { startFromScratch = true; canRetry = true; canExtend = false; } }
private void fetchRequestToken() { OAuthAccessor accessor = accessorInfo.getAccessor(); sRequest request = new sRequest(Uri.parse(accessor.consumer.serviceProvider.requestTokenURL)); request.setMethod(accessorInfo.getHttpMethod().ToString()); if (accessorInfo.getHttpMethod().CompareTo(AccessorInfo.HttpMethod.POST) == 0) { request.setContentType(OAuth.FORM_ENCODED); } sRequest signed = sanitizeAndSign(request, null); OAuthMessage reply = sendOAuthMessage(signed); accessor.requestToken = reply.getParameter(OAuth.OAUTH_TOKEN); accessor.TokenSecret = reply.getParameter(OAuth.OAUTH_TOKEN_SECRET); }
private String getParameter(OAuthMessage requestMessage, String key) { try { return(requestMessage.getParameter(key)); } catch { return(null); } }
/** * Look for an OAuth protocol problem. For cases where no access token is in play * @param response * @throws OAuthProtocolException * @throws IOException */ private void checkForProtocolProblem(sResponse response) { if (isFullOAuthError(response)) { OAuthMessage message = parseAuthHeader(null, response); if (message.getParameter(OAuthProblemException.OAUTH_PROBLEM) != null) { // SP reported extended error information throw new OAuthProtocolException(message); } // No extended information, guess based on HTTP response code. throw new OAuthProtocolException(response.getHttpStatusCode()); } }
public static String getParameter(OAuthMessage message, String name) { return(message.getParameter(name)); }