當前位置: 首頁>>代碼示例>>Java>>正文


Java OAuthRequest.addQuerystringParameter方法代碼示例

本文整理匯總了Java中org.scribe.model.OAuthRequest.addQuerystringParameter方法的典型用法代碼示例。如果您正苦於以下問題:Java OAuthRequest.addQuerystringParameter方法的具體用法?Java OAuthRequest.addQuerystringParameter怎麽用?Java OAuthRequest.addQuerystringParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.scribe.model.OAuthRequest的用法示例。


在下文中一共展示了OAuthRequest.addQuerystringParameter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: send

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
private String send(Verb verb, String params) throws Exception {
    String url = apiUrl + ((params != null) ? params : "");
    
    OAuthRequest request = new OAuthRequest(verb, url);
    request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, apiAccessToken);
    
    // For more details on the “Bearer” token refer to http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-23
    StringBuilder sb = new StringBuilder();
    sb.append("Bearer ");
    sb.append(apiAccessToken);
    request.addHeader("Authorization",  sb.toString());

    if (LOG.isDebugEnabled()) {
        LOG.debug("Yammer request url: {}", request.getCompleteUrl());
    }
    
    Response response = request.send();
    if (response.isSuccessful()) {                    
        return response.getBody();
    } else {
        throw new Exception(String.format("Failed to poll %s. Got response code %s and body: %s", getApiUrl(), response.getCode(), response.getBody()));
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:24,代碼來源:ScribeApiRequestor.java

示例2: appendSignature

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
private void appendSignature(OAuthRequest request)
{
  switch (config.getSignatureType())
  {
    case Header:
      config.log("using Http Header signature");

      String oauthHeader = api.getHeaderExtractor().extract(request);
      request.addHeader(OAuthConstants.HEADER, oauthHeader);
      break;
    case QueryString:
      config.log("using Querystring signature");

      for (Map.Entry<String, String> entry : request.getOauthParameters().entrySet())
      {
        request.addQuerystringParameter(entry.getKey(), entry.getValue());
      }
      break;
  }
}
 
開發者ID:edgehosting,項目名稱:jira-dvcs-connector,代碼行數:21,代碼來源:HttpClientThrreeLoOAuth10aServiceImpl.java

示例3: getAccessToken

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
@Override
public Token getAccessToken(Token requestToken, Verifier verifier) {
    OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
    switch (api.getAccessTokenVerb()) {
    case POST:
        request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
        request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
        request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
        request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
        request.addBodyParameter(GRANT_TYPE, GRANT_TYPE_AUTHORIZATION_CODE);
        break;
    case GET:
    default:
        request.addQuerystringParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
        request.addQuerystringParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
        request.addQuerystringParameter(OAuthConstants.CODE, verifier.getValue());
        request.addQuerystringParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
        if(config.hasScope()) request.addQuerystringParameter(OAuthConstants.SCOPE, config.getScope());
    }
    Response response = request.send();
    return api.getAccessTokenExtractor().extract(response.getBody());
}
 
開發者ID:elimu-ai,項目名稱:webapp,代碼行數:23,代碼來源:Google2Api.java

示例4: appendSignature

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
private void appendSignature(OAuthRequest request)
{
	switch (config.getSignatureType())
	{
	case Header:
		config.log("using Http Header signature");

		String oauthHeader = api.getHeaderExtractor().extract(request);
		request.addHeader(OAuthConstants.HEADER, oauthHeader);
		break;
	case QueryString:
		config.log("using Querystring signature");

		for (Map.Entry<String, String> entry : request.getOauthParameters().entrySet())
		{
			request.addQuerystringParameter(entry.getKey(), entry.getValue());
		}
		break;
	}
}
 
開發者ID:edgehosting,項目名稱:jira-dvcs-connector,代碼行數:21,代碼來源:TwoLoOAuth10aServiceImpl.java

示例5: getAuthorizationUrl

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
@Override
public String getAuthorizationUrl(OAuthConfig config, String state) {

    // http://wiki.connect.qq.com/%E4%BD%BF%E7%94%A8authorization_code%E8%8E%B7%E5%8F%96access_token

    final String authorizationEndpoint = "https://graph.qq.com/oauth2.0/authorize";

    OAuthRequest request = new OAuthRequest(Verb.GET, authorizationEndpoint);
    request.addQuerystringParameter("response_type", "code");
    request.addQuerystringParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
    request.addQuerystringParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
    request.addQuerystringParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
    request.addQuerystringParameter("state", state);
    if (config.hasScope()) {
        request.addQuerystringParameter(OAuthConstants.SCOPE, config.getScope());
    }
    return request.getCompleteUrl();
}
 
開發者ID:btpka3,項目名稱:pac4j-oauth-tencent,代碼行數:19,代碼來源:TencentApi.java

示例6: signRequest

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
@Override
public void signRequest(final Token accessToken, final OAuthRequest request) {
    request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken());
    String response = accessToken.getRawResponse();
    Matcher matcher = openIdPattern.matcher(response);
    if (matcher.find()) {
        request.addQuerystringParameter("openid", matcher.group(1));
    } else {
        throw new OAuthException("微信接口返回數據miss openid: " + response);
    }
}
 
開發者ID:luotuo,項目名稱:cas4.0.x-server-wechat,代碼行數:12,代碼來源:WeiXinOAuth20ServiceImpl.java

示例7: signRequest

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
@Override
public void signRequest(Token accessToken, OAuthRequest request) {
	switch (config.getSignatureType()) {
	case Header:
		config.log("using Http Header signature");
		request.addHeader(OAuthConstants.HEADER, bearerName + " " + accessToken.getToken());
		break;
	case QueryString:
		config.log("using Querystring signature");
		request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken());
		break;
	}
}
 
開發者ID:plekhotkindmytro,項目名稱:Linkedin-oAuth2.0,代碼行數:14,代碼來源:OAuth20ThreeLeggedServiceImpl.java

示例8: getAccessToken

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
@Override
public Token getAccessToken(Token requestToken, Verifier verifier) {
    OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
    request.addQuerystringParameter("grant_type", "authorization_code");
    request.addQuerystringParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
    request.addQuerystringParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
    request.addQuerystringParameter(OAuthConstants.CODE, verifier.getValue());
    request.addQuerystringParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
    if (config.hasScope())
        request.addQuerystringParameter(OAuthConstants.SCOPE, config.getScope());
    Response response = request.send();
    return api.getAccessTokenExtractor().extract(response.getBody());
}
 
開發者ID:btpka3,項目名稱:pac4j-oauth-tencent,代碼行數:14,代碼來源:TencentOAuth20ServiceImpl.java

示例9: addUrlParams

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
private void addUrlParams(OAuthRequest request, Map.Entry<String, String>... params) {
	for (Map.Entry<String, String> pair : params) {
		if (pair != null) {
			request.addQuerystringParameter(pair.getKey(), pair.getValue());
		}
	}
}
 
開發者ID:Openredu,項目名稱:mobile,代碼行數:8,代碼來源:ScribeHttpClient.java

示例10: searchByBusinessId

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
/**
 * Creates and sends a request to the Business API by business ID with additional params.
 * <p>
 * See <a href="http://www.yelp.com/developers/documentation/v2/business">Yelp Business API V2</a>
 * for more info.
 *
 * @param businessID <tt>String</tt> business ID of the requested business
 * @param searchRequest SearchRequest pojo used to provide parameters
 * @return <tt>String</tt> JSON Response
 */
public Business searchByBusinessId(String businessID, SearchRequest searchRequest) {
    OAuthRequest request = createOAuthRequest(BUSINESS_PATH + "/" + businessID);
    if (searchRequest.getCountryCode() != null) {
        request.addQuerystringParameter("cc", searchRequest.getCountryCode());
    }
    if (searchRequest.getLanguage() != null) {
        request.addQuerystringParameter("lang", searchRequest.getLanguage());
    }
    if (searchRequest.getActionLinks() != null) {
        request.addQuerystringParameter("actionlinks", searchRequest.getActionLinks().toString());
    }
    return sendRequestAndGetResponse(request, Business.class);
}
 
開發者ID:brwagner,項目名稱:yelp-api-java-wrapper,代碼行數:24,代碼來源:YelpAPI.java

示例11: signRequest

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
@Override
public void signRequest(Token token, OAuthRequest request) {
  request.addQuerystringParameter(ACCESS_TOKEN, token.getToken());
}
 
開發者ID:davido,項目名稱:gerrit-oauth-provider,代碼行數:5,代碼來源:BitbucketApi.java

示例12: getUserInfo

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
@Override
public OAuthUserInfo getUserInfo(OAuthToken token) throws IOException {
  OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
  Token t = new Token(token.getToken(), token.getSecret(), token.getRaw());
  request.addQuerystringParameter(FIELDS_QUERY, FIELDS);
  service.signRequest(t, request);
  Response response = request.send();

  if (response.getCode() != HttpServletResponse.SC_OK) {
    throw new IOException(
        String.format(
            "Status %s (%s) for request %s",
            response.getCode(), response.getBody(), request.getUrl()));
  }
  JsonElement userJson =
      OutputFormat.JSON.newGson().fromJson(response.getBody(), JsonElement.class);

  if (log.isDebugEnabled()) {
    log.debug("User info response: {}", response.getBody());
  }
  if (userJson.isJsonObject()) {
    JsonObject jsonObject = userJson.getAsJsonObject();
    JsonElement id = jsonObject.get("id");
    if (id == null || id.isJsonNull()) {
      throw new IOException(String.format("Response doesn't contain id field"));
    }
    JsonElement email = jsonObject.get("email");
    JsonElement name = jsonObject.get("name");
    // Heads up!
    // Lets keep `login` equal to `email`, since `username` field is
    // deprecated for Facebook API versions v2.0 and higher
    JsonElement login = jsonObject.get("email");

    return new OAuthUserInfo(
        FACEBOOK_PROVIDER_PREFIX + id.getAsString(),
        login == null || login.isJsonNull() ? null : login.getAsString(),
        email == null || email.isJsonNull() ? null : email.getAsString(),
        name == null || name.isJsonNull() ? null : name.getAsString(),
        null);
  }

  throw new IOException(String.format("Invalid JSON '%s': not a JSON Object", userJson));
}
 
開發者ID:davido,項目名稱:gerrit-oauth-provider,代碼行數:44,代碼來源:FacebookOAuthService.java

示例13: signRequest

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
@Override
public void signRequest(Token accessToken, OAuthRequest request) {
  request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken());
}
 
開發者ID:davido,項目名稱:gerrit-oauth-provider,代碼行數:5,代碼來源:OAuth20ServiceImpl.java

示例14: getProfileUrl

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
protected String getProfileUrl(Token accessToken) {
    OAuthRequest request = new OAuthRequest(Verb.GET, OPEN_ID_URL);
    request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken());
    return request.getCompleteUrl();
}
 
開發者ID:btpka3,項目名稱:pac4j-oauth-tencent,代碼行數:6,代碼來源:TencentClient.java

示例15: searchForBusinessesByLocation

import org.scribe.model.OAuthRequest; //導入方法依賴的package包/類
/**
 * Creates and sends a request to the Search API by term and location.
 * <p>
 * See <a href="http://www.yelp.com/developers/documentation/v2/search_api">Yelp Search API V2</a>
 * for more info.
 *
 * @param searchRequest pojo containing search parameters
 * @return <tt>String</tt> JSON Response
 */
public SearchResult searchForBusinessesByLocation(SearchRequest searchRequest) {
    OAuthRequest request = createOAuthRequest(SEARCH_PATH);
    if (searchRequest.getTerm() != null) {
        request.addQuerystringParameter("term", searchRequest.getTerm());
    }
    if (searchRequest.getLimit() != null) {
        request.addQuerystringParameter("limit", searchRequest.getLimit().toString());
    }
    if (searchRequest.getOffset() != null) {
        request.addQuerystringParameter("offset", searchRequest.getOffset().toString());
    }
    if (searchRequest.getSort() != null) {
        request.addQuerystringParameter("sort", searchRequest.getSort().id().toString());
    }
    if (searchRequest.getCategoryFilter() != null) {
        request.addQuerystringParameter("category_filter", searchRequest.getCategoryFilter());
    }
    if (searchRequest.getRadiusFilter() != null) {
        request.addQuerystringParameter("radius_filter", searchRequest.getRadiusFilter().toString());
    }
    if (searchRequest.getDealsFilter() != null) {
        request.addQuerystringParameter("deals_filter", searchRequest.getDealsFilter().toString());
    }
    if (searchRequest.getLocation() != null) {
        request.addQuerystringParameter("location", searchRequest.getLocation());
        if (searchRequest.getLatitude() != null && searchRequest.getLongitude() != null) {
            String cll = searchRequest.getLatitude() + "," + searchRequest.getLongitude();
            request.addQuerystringParameter("cll", cll);
        }
    }
    if (searchRequest.getSwLatitude() != null && searchRequest.getSwLongitude() != null
        && searchRequest.getNeLatitude() != null && searchRequest.getNeLongitude() != null) {
        String bounds = searchRequest.getSwLatitude() + "," +
            searchRequest.getSwLongitude() + "|" +
            searchRequest.getNeLatitude() + "," +
            searchRequest.getNeLongitude();
        request.addQuerystringParameter("bounds", bounds);
    }
    if (searchRequest.getLanguage() == null && searchRequest.getLatitude() != null
        && searchRequest.getLongitude() != null) {
        String ll = searchRequest.getLatitude() + "," +
            searchRequest.getLongitude() + "," +
            searchRequest.getAccuracy() + "," +
            searchRequest.getAltitude() + "," +
            searchRequest.getAltitudeAccuracy();
        request.addQuerystringParameter("ll", ll);
    }
    if (searchRequest.getCountryCode() != null) {
        request.addQuerystringParameter("cc", searchRequest.getCountryCode());
    }
    if (searchRequest.getLanguage() != null) {
        request.addQuerystringParameter("lang", searchRequest.getLanguage());
    }
    if (searchRequest.getActionLinks() != null) {
        request.addQuerystringParameter("actionlinks", searchRequest.getActionLinks().toString());
    }
    return sendRequestAndGetResponse(request, SearchResult.class);
}
 
開發者ID:brwagner,項目名稱:yelp-api-java-wrapper,代碼行數:68,代碼來源:YelpAPI.java


注:本文中的org.scribe.model.OAuthRequest.addQuerystringParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。