当前位置: 首页>>代码示例>>Java>>正文


Java Verb.GET属性代码示例

本文整理汇总了Java中com.github.scribejava.core.model.Verb.GET属性的典型用法代码示例。如果您正苦于以下问题:Java Verb.GET属性的具体用法?Java Verb.GET怎么用?Java Verb.GET使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.github.scribejava.core.model.Verb的用法示例。


在下文中一共展示了Verb.GET属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

public static void main (String[] args) {
    ResourceBundle secrets = ResourceBundle.getBundle("facebookutil/secret");
    final OAuth20Service service = new ServiceBuilder()
            .apiKey(secrets.getString("clientId"))
            .apiSecret(secrets.getString("clientSecret"))
            .callback("https://duke.edu/")
            .grantType("client_credentials")
            .build(FacebookApi.instance());
    String url = "https://graph.facebook.com/oauth/access_token?";
    url = url + "&client_id" + "=" + secrets.getString("clientId");
    url = url + "&client_secret" + "=" + secrets.getString("clientSecret");
    url = url + "&grant_type" + "=" + "client_credentials";
    final OAuthRequest request =
            new OAuthRequest(Verb.GET, url, service);
    service.signRequest(new OAuth2AccessToken(""), request);
    System.out.println(request.getBodyContents());
    System.out.println(request.getUrl());
    Response response = request.send();
    System.out.println(response.getBody());
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:20,代码来源:TestAppLogin.java

示例2: validate

@Override
public CredentialValidationResult validate(Credential credential) {
    if (credential instanceof TokenResponseCredential) {
        TokenResponseCredential tokenCredential = (TokenResponseCredential) credential;

        OAuthRequest request = new OAuthRequest(Verb.GET, "https://www.googleapis.com/oauth2/v3/userinfo");

        OAuth20Service service = tokenCredential.getService();
        OAuth2AccessToken token = tokenCredential.getTokenResponse();
        service.signRequest(token, request);

        try {
            Response oResp = service.execute(request);
            String body = oResp.getBody();

            OAuth2User oAuth2User = jsonProcessor.extractUserInfo(body);

            return new CredentialValidationResult(oAuth2User);

        } catch (InterruptedException | ExecutionException | IOException e) {
            e.printStackTrace(); // FIXME
        }

    }
    return CredentialValidationResult.NOT_VALIDATED_RESULT;
}
 
开发者ID:atbashEE,项目名称:jsr375-extensions,代码行数:26,代码来源:DemoIdentityStore.java

示例3: loadOAuthProviderAccount

public OAuthProviderAccount loadOAuthProviderAccount(Token accessToken, OAuthProviderName provider) {
	OAuthService service = this.getService();

	// getting user profile
	OAuthRequest oauthRequest = new OAuthRequest(Verb.GET, config.getProfileUrl(), service);
	service.signRequest(accessToken, oauthRequest); // the access token from step 4

	Response oauthResponse = oauthRequest.send();

	String jsonString = oauthResponse.getBody();
	JSONObject root = new JSONObject(jsonString);

	String accountId = String.valueOf(root.getInt(TWITTER_ACCTID_PROPERTY)); 
	String displayName = root.getString(TWITTER_DISPLAYNAME_PROPERTY);
	String publicId = root.getString(TWITTER_SCREENNAME_PROPERTY); 
	String profilePath = provider.getIdProviderUrl() + "/" + publicId; 
	
	OAuthProviderAccount profile = 
			new OAuthProviderAccount(accessToken, provider, displayName, accountId, publicId , profilePath);

	return profile;
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:22,代码来源:TwitterOAuthProvider.java

示例4: doInBackground

protected AccountData doInBackground(Void... voids) {
    AccountData aData = new AccountData();

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.GET, tk.getFullAccountInfo(), service);
    service.signRequest(accessToken, request);
    Response response = request.send();

    //parse json
    try {
        aData = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
        aData.setError(e.toString());
    }

    return aData;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:25,代码来源:ParseAccountData.java

示例5: doInBackground

protected StockQuote doInBackground(Void... voids){
    //pause for a second so we don't get rate limited
    SystemClock.sleep(1000);

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.GET, tk.getMarketQuote(symbol), service);
    service.signRequest(accessToken, request);
    Response response = request.send();

    StockQuote quote = new StockQuote(symbol);
    try {
        quote = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
        quote.setError(e.toString());
    }

    return quote;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:26,代码来源:ParseStockQuote.java

示例6: doInBackground

protected Double doInBackground(Void... voids){
    double ret = 0.0;

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.GET, tk.getOptionStrikePrices(symbol), service);
    service.signRequest(accessToken, request);
    Response response = request.send();

    try {
        ret = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return ret;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:23,代码来源:ParseOptionStrikePrice.java

示例7: processRequest

private void processRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException {
	String code = req.getParameter("code");
	LOGGER.info("OAuth2 code: [{}]", code);
	String provider = StringUtils.substringAfterLast(req.getRequestURI(), "/");
	LOGGER.info("Provider: [{}]", provider);
	OAuth20Service oAuth2Service = this.providerFactory.getOAuth2Service(provider);
	OAuth2AccessToken token = null;
	try {
		token = oAuth2Service.getAccessToken(code);
		LOGGER.info("OAuth2AccessToken: [{}]", token);
		OAuthRequest oReq = new OAuthRequest(Verb.GET, "https://api.linkedin.com/v1/people/~?format=json");
		oAuth2Service.signRequest(token, oReq);
		Response oResp = oAuth2Service.execute(oReq);
		LOGGER.info("Linkedin Profile: [{}]", oResp.getBody());
		resp.getOutputStream().write(oResp.getBody().getBytes(StandardCharsets.UTF_8));
	} catch (InterruptedException | ExecutionException ex) {
	}
}
 
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:18,代码来源:OAuth2CallbackServlet.java

示例8: isOrganizationMember

/**
 * Check to see that login is a member of organization.
 *
 * A 204 response code indicates organization membership.  302 and 404 codes are not treated as exceptional,
 * they indicate various ways in which a login is not a member of the organization.
 *
 * @see <a href="https://developer.github.com/v3/orgs/members/#response-if-requester-is-an-organization-member-and-user-is-a-member">GitHub members API</a>
 */
private boolean isOrganizationMember(OAuth2AccessToken accessToken, String organization, String login) throws IOException, ExecutionException, InterruptedException {
  String requestUrl = settings.apiURL() + format("orgs/%s/members/%s", organization, login);
  OAuth20Service scribe = new ServiceBuilder(settings.clientId())
    .apiSecret(settings.clientSecret())
    .build(scribeApi);
  OAuthRequest request = new OAuthRequest(Verb.GET, requestUrl);
  scribe.signRequest(accessToken, request);

  Response response = scribe.execute(request);
  int code = response.getCode();
  switch (code) {
    case HttpURLConnection.HTTP_MOVED_TEMP:
    case HttpURLConnection.HTTP_NOT_FOUND:
    case HttpURLConnection.HTTP_NO_CONTENT:
      LOGGER.trace("Orgs response received : {}", code);
      return code == HttpURLConnection.HTTP_NO_CONTENT;
    default:
      throw unexpectedResponseCode(requestUrl, response);
  }
}
 
开发者ID:SonarSource,项目名称:sonar-auth-github,代码行数:28,代码来源:GitHubIdentityProvider.java

示例9: getMethod

public static Verb getMethod(String method) {
	switch (method) {
		case "GET":
			return Verb.GET;
		case "POST":
			return Verb.POST;
		case "DELETE":
			return Verb.DELETE;
		case "PUT":
			return Verb.PUT;
		case "PATCH":
			return Verb.PATCH;
		case "OPTIONS":
			return Verb.OPTIONS;
	}
	throw new IllegalStateException(method);
}
 
开发者ID:codepath,项目名称:android-oauth-handler,代码行数:17,代码来源:ScribeRequestAdapter.java

示例10: loadOAuthProviderAccount

public OAuthProviderAccount loadOAuthProviderAccount(Token accessToken, OAuthProviderName provider) {

	OAuthService service = this.getService();

	// getting user profile
	OAuthRequest oauthRequest = new OAuthRequest(Verb.GET, config.getProfileUrl(), service);

	service.signRequest(accessToken, oauthRequest);
	Response oauthResponse = oauthRequest.send();
	String jsonString = oauthResponse.getBody();
	JSONObject root = new JSONObject(jsonString);
	JSONArray emailArray = root.getJSONArray(GOOGLE_JSON_EMAILLIST_PROPERTY);
	JSONObject firstEmail = emailArray.getJSONObject(0);

	String accountId = root.getString(GOOGLE_JSON_ACCOUNTID_PROPERTY); 
	String displayName = root.getString(GOOGLE_JSON_DISPLAYNAME_PROPERTY);
	String publicId = firstEmail.getString(GOOGLE_JSON_EMAIL_PROPERTY); 
	String profilePath="";
	if (root.has(GOOGLE_JSON_PROFILEPATH_PROPERTY)){
		profilePath = root.getString(GOOGLE_JSON_PROFILEPATH_PROPERTY); 
	}
	
	OAuthProviderAccount profile = 
			new OAuthProviderAccount(accessToken, provider, displayName, accountId, publicId , profilePath);
		
	return profile;
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:27,代码来源:GoogleOAuthProvider.java

示例11: doInBackground

protected MarketDay doInBackground(Void... arg0){

        //not sure if this is right if the assignment below will happen correctly.
        MarketDay marketDay = new MarketDay();

        //Build the OAuth service
        final OAuth10aService service = new ServiceBuilder()
                .apiKey(apiKeys.CONSUMER_KEY)
                .apiSecret(apiKeys.CONSUMER_SECRET)
                .build(TradeKingApi.instance());
        Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

        // Fetch the JSON data
        OAuthRequest request = new OAuthRequest(Verb.GET, tk.getMarketYesterdaysMinuteData(symbol), service);
        service.signRequest(accessToken, request);
        Response response = request.send();

        //try parsing the JSON data.
        try {
            marketDay = parseJSON(response);
        } catch (JSONException e) {
            e.printStackTrace();
            marketDay.setError(e.toString());
        }

        return marketDay;
    }
 
开发者ID:mikemey01,项目名称:Markets,代码行数:27,代码来源:ParseData.java

示例12: doInBackground

protected OpenOptionPosition doInBackground(Void... voids){
    //sleep for a second for rate limiting.
    SystemClock.sleep(1000);

    OpenOptionPosition openOptionPosition = new OpenOptionPosition();

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.GET, tk.getOpenOptionPositions(), service);
    service.signRequest(accessToken, request);
    Response response = request.send();

    try {
        openOptionPosition = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
        openOptionPosition.setError(e.toString());
    }

    return openOptionPosition;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:27,代码来源:ParseOpenPosition.java

示例13: callback

@Override
public void callback(CallbackContext context) {
  context.verifyCsrfState();

  HttpServletRequest request = context.getRequest();
  OAuth20Service scribe = prepareScribe(context).build(GoogleApi20.instance());
  String oAuthVerifier = request.getParameter("code");
  OAuth2AccessToken accessToken = scribe.getAccessToken(new Verifier(oAuthVerifier));

  OAuthRequest userRequest = new OAuthRequest(Verb.GET, "https://www.googleapis.com/oauth2/v2/userinfo", scribe);
  scribe.signRequest(accessToken, userRequest);

  com.github.scribejava.core.model.Response userResponse = userRequest.send();
  if (!userResponse.isSuccessful()) {
    throw new IllegalStateException(format("Fail to authenticate the user. Error code is %s, Body of the response is %s",
      userResponse.getCode(), userResponse.getBody()));
  }
  String userResponseBody = userResponse.getBody();
  LOGGER.trace("User response received : %s", userResponseBody);
  GsonUser gsonUser = GsonUser.parse(userResponseBody);

  UserIdentity userIdentity = UserIdentity.builder()
    .setProviderLogin(gsonUser.getEmail())
    .setLogin(gsonUser.getEmail())
    .setName(gsonUser.getName())
    .setEmail(gsonUser.getEmail())
    .build();
  context.authenticate(userIdentity);
  context.redirectToRequestedPage();
}
 
开发者ID:steven-turner,项目名称:sonar-auth-google,代码行数:30,代码来源:GoogleIdentityProvider.java

示例14: getOpenId

public String getOpenId(OAuth2AccessToken accessToken, OAuth20Service service) {
    final OAuthRequest request = new OAuthRequest(Verb.GET, GET_OPEN_ID_URL, service);
    service.signRequest(accessToken, request);
    Response response = request.send();
    String rawResponse = null;
    try {
        rawResponse = response.getBody();
    } catch (IOException e) {

    }
    String formattedStr = rawResponse.substring(rawResponse.indexOf("{"), rawResponse.indexOf("}") + 1);
    return JsonUtil.getString("openid", formattedStr);
}
 
开发者ID:perrywang,项目名称:OAuthGateway,代码行数:13,代码来源:QQService.java

示例15: authenticated

@Override
public GatewayResponse authenticated(String state, String code) {
    OAuth20Service service = getOAuthServiceProvider(state);
    GatewayAccessToken accessToken = getAccessToken(state, code);
    checkToken(accessToken);
    String openId = getOpenId(accessToken, service);
    EventPublisher.instance().publishEvent(new AccessTokenRetrievedEvent(state, accessToken));
    final OAuthRequest request = new OAuthRequest(Verb.GET,
            getUserInfoUrl() + "?oauth_consumer_key=" + qqConfig.getApiKey() + "&openid=" + openId, service);
    service.signRequest(accessToken, request);
    Response response = request.send();
    return parseUserInfoResponse(response);
}
 
开发者ID:perrywang,项目名称:OAuthGateway,代码行数:13,代码来源:QQService.java


注:本文中的com.github.scribejava.core.model.Verb.GET属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。