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


Java OAuthService.signRequest方法代码示例

本文整理汇总了Java中org.scribe.oauth.OAuthService.signRequest方法的典型用法代码示例。如果您正苦于以下问题:Java OAuthService.signRequest方法的具体用法?Java OAuthService.signRequest怎么用?Java OAuthService.signRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.scribe.oauth.OAuthService的用法示例。


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

示例1: afterFinalUriConstructed

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
@Override
protected String afterFinalUriConstructed(HttpRequestBase forMethod, String finalUri, Map<String, ? extends Object> parameters)
{
    long start = System.currentTimeMillis();
	//
	// generate oauth 1.0 params for 2LO - use scribe so far for that ...
	//
	OAuthService service = createOauthService();
	OAuthRequest request = new OAuthRequest(Verb.valueOf(forMethod.getMethod()), finalUri);

	addParametersForSigning(request, parameters);

	service.signRequest(new EmptyToken(), request);
	Map<String, String> oauthParams = request.getOauthParameters();
	//
	//
	log.debug("2LO signing took [{}] ms ", System.currentTimeMillis() - start);

	return finalUri + paramsToString(oauthParams, finalUri.indexOf("?") != -1);
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:21,代码来源:TwoLegged10aOauthRemoteRequestor.java

示例2: onConnectionCreated

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
@Override
protected void onConnectionCreated(HttpClient client, HttpRequestBase method, Map<String, ? extends Object> parameters)
        throws IOException
{
    long start = System.currentTimeMillis();
    //
    // generate oauth 1.0 params for 3LO - use scribe so far for that ...
    //
    OAuthService service = createOauthService();
    OAuthRequest request = new OAuthRequest(Verb.valueOf(method.getMethod()), method.getURI().toString());

    addParametersForSigning(request, parameters);

    service.signRequest(generateAccessTokenObject(accessTokenWithSecret), request);

    String header = authHeaderCreator.extract(request);
    method.addHeader(OAuthConstants.HEADER, header);

    log.debug("3LO signing took [{}] ms ", System.currentTimeMillis() - start);
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:21,代码来源:ThreeLegged10aOauthRemoteRequestor.java

示例3: getUserInfoJSON

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private JSONObject getUserInfoJSON(String code, String callBackUrl) {
    OAuthService service = new ServiceBuilder()
            .provider(FacebookApi.class)
            .apiKey(apiKey)
            .apiSecret(apiSecret)
            .callback(host + callBackUrl)
            .scope("email")
            .build();
    Verifier verifier = new Verifier(code);
    Token accessToken = service.getAccessToken(NULL_TOKEN, verifier);
    OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
    request.addOAuthParameter("scope", "email");
    service.signRequest(accessToken, request);
    Response response = request.send();
    LOG.info("response body is " + response.getBody());
    try {
        JSONObject obj = new JSONObject(response.getBody());
        obj.put("access_token", accessToken.getToken());
        return obj;
    } catch (JSONException e) {
        return new JSONObject();
    }
}
 
开发者ID:cilogi,项目名称:lid,代码行数:24,代码来源:FacebookLoginServlet.java

示例4: getSocialUser

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private SocialUser getSocialUser(Token accessToken,int authProvider) throws OurException
{
    logger.info("Token: " + accessToken + " Provider: " + authProvider);
    OAuthService service = getOAuthService(authProvider);
    
    
    String url = getProtectedResourceUrlFromSession();
    logger.info("protected url: " + url);
    OAuthRequest request = new OAuthRequest(Verb.GET,url);
    // sign the request
    service.signRequest(accessToken,request);
    Response response = request.send();
    String json = response.getBody();
    SocialUser socialUser = getSocialUserFromJson(json,authProvider);
    return socialUser;
}
 
开发者ID:muquit,项目名称:gwtoauthlogindemo,代码行数:17,代码来源:OAuthLoginServiceImpl.java

示例5: send

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
public E send(OAuthService oAuthService, Token accessToken) {
	OAuthRequest request = getRequest();
	oAuthService.signRequest(accessToken, request);

	Response response = null;

	long tsStart = System.currentTimeMillis();
	try {
		System.out.println("[REQUEST] " + request.getVerb() + " "
				+ request.getCompleteUrl());
		response = request.send();
		System.out.println("> " + response.getBody());
	} finally {
		long tsEnd = System.currentTimeMillis();
		System.out.println("[REQUEST] SC=" + response.getCode() + " in "
				+ (tsEnd - tsStart) + "ms <- " + request.getVerb() + " "
				+ request.getCompleteUrl());
	}

	soupErrorHandler.handle(request, response);

	return convertResponse(response);
}
 
开发者ID:soup,项目名称:clients,代码行数:24,代码来源:SoupRequestImpl.java

示例6: retrieveEntitySample1

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
public SampleEntity retrieveEntitySample1(Token accessToken) throws ClientException
{
	OAuthService service = getOAuthService(scopes, null);
	
	OAuthRequest request = new OAuthRequest(Verb.GET,
			"http://localhost:9998/testsuite/rest/sample/1");
	service.signRequest(accessToken, request);
	Response response = request.send();
	if (response.getCode()!=200)
		throwClientException(response);
	
	ObjectMapper mapper = new ObjectMapper();
	try {
		SampleEntity entity = mapper.readValue(response.getBody(), SampleEntity.class);
		return entity;
	} catch (IOException e) {
		throw new ClientException(response.getBody());
	}
}
 
开发者ID:hburgmeier,项目名称:jerseyoauth2,代码行数:20,代码来源:ResourceClient.java

示例7: getUserBlogs

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
public static List<String> getUserBlogs(Token accToken) throws IOException {
    String userInformationUrl = "http://api.tumblr.com/v2/user/info";
    OAuthService service = new ServiceBuilder().apiKey(consumer_key).apiSecret(secret_key).provider(TumblrApi.class).build();
    OAuthRequest request = new OAuthRequest(Verb.GET, userInformationUrl);
    service.signRequest(accToken, request);
    Response response = request.send();

    ObjectMapper mapper = new ObjectMapper();
    JsonNode jBlogs = mapper.readTree(response.getBody()).get("response").get("user").get("blogs");

    List<String> blogs = new ArrayList<>();

    for (JsonNode jBlog : jBlogs) {
        blogs.add(jBlog.get("name").toString());
    }

    return blogs;
}
 
开发者ID:anycook,项目名称:anycook-api,代码行数:19,代码来源:Tumblr.java

示例8: postRecipe

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
public static String postRecipe(Token accToken, String recipeName, String host) throws UnsupportedEncodingException {
        OAuthService service = new ServiceBuilder().apiKey(consumer_key).apiSecret(secret_key).provider(TumblrApi.class).build();
        String url = String.format(POST_URL, host);
        OAuthRequest request = new OAuthRequest(Verb.POST, url);

        StringBuffer sb = new StringBuffer();
        sb.append("de.anycook, recipe");
//		for(String tag : recipe.tags){
//			sb.append(", ").append(tag);
//		}

        String photourl = String.format("api.anycook.de/recipe/%s/image?type=large", URLEncoder.encode(recipeName, "UTF-8"));
        request.addBodyParameter("type", "photo");
        request.addBodyParameter("link", "http://de.anycook.de/#!/recipe/" + URLEncoder.encode(recipeName, "UTF-8"));
        request.addBodyParameter("source", photourl);
        request.addBodyParameter("tags", sb.toString());
        request.addBodyParameter("slug", "via de.anycook.de");
        service.signRequest(accToken, request);
        return request.send().getBody();

    }
 
开发者ID:anycook,项目名称:anycook-api,代码行数:22,代码来源:Tumblr.java

示例9: getAttributeProfile

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
@Override
public Response getAttributeProfile(long customerId, int clientId, String attribute) {
    if (!IdPool.clientInList(customerId, clientId)) {
        clientNotFoundMsg.setCustomerId(customerId);
        clientNotFoundMsg.setClientId(clientId);
        return Response.status(Response.Status.OK).entity(clientNotFoundMsg).type(MediaType.APPLICATION_JSON_TYPE).build();
    }

    customer = LinkedInCustomerResource.getCustomerList().get(customerId);
    client = customer.getClientDB().getClientList().get(clientId);

    if (client.getStatus() == linkStatusOff) {
        notLinkedMsg = new NotLinked();
        notLinkedMsg.setCustomerId(customerId);
        notLinkedMsg.setClientId(clientId);
        return Response.status(Response.Status.OK).entity(notLinkedMsg).type(MediaType.APPLICATION_JSON_TYPE).build();
    }


    OAuthRequest request = new OAuthRequest(Verb.GET, LinkedInAppResource.API_BASIC_PROFILE_URI + ":(" + attribute + ")");
    request.addHeader("x-li-format", "json");
    OAuthService service = client.getLinkHandler().getServiceProvider();
    service.signRequest(client.getLinkHandler().getAccessToken(), request);
    org.scribe.model.Response response = request.send();

    return Response.status(Response.Status.OK).entity(response.getBody()).build();
}
 
开发者ID:ZhengshuaiPENG,项目名称:HiringSmV02,代码行数:28,代码来源:LinkedInAppResource.java

示例10: execute

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private void execute(String payment) {
    final OAuthRequest request = new OAuthRequest(Verb.POST, getString(R.string.payment));
    request.addBodyParameter("category_id", "101");
    request.addBodyParameter("genre_id", "10101");
    request.addBodyParameter("amount", payment);
    String date = DateFormat.format("'yyyy'-'MM'-'dd'", Calendar.getInstance()).toString();
    request.addBodyParameter("date", date);
    request.addBodyParameter("from_account_id", "1");
    final Token accessToken = ZaimUtils.getAccessToken(getApplicationContext());
    final OAuthService service = ZaimUtils.getOauthService(getApplicationContext());
    service.signRequest(accessToken, request);
    request.send();
}
 
开发者ID:hotchemi,项目名称:wearzaim,代码行数:14,代码来源:PostPaymentService.java

示例11: doAccessAuth

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private TwitterAuthDoneEvent doAccessAuth( Token requestToken, String oauthVerifier )
{
    Token accessToken = null;
    String userName = null;
    try
    {
        OAuthService service = new ServiceBuilder()
                .provider( TwitterApi.SSL.class )
                .callback( TwitterLoginActivity.TWITTER_CALLBACK_URL )
                .apiKey( TwitterConfig.TWITTER_OAUTH_CONSUMER_KEY )
                .apiSecret( TwitterConfig.TWITTER_OAUTH_CONSUMER_SECRET )
                .build();
        accessToken = service.getAccessToken( requestToken, new Verifier( oauthVerifier ) );

        // Once we have the access token, we do a quick and dirty request to get the username
        OAuthRequest request = new OAuthRequest( Verb.GET, TWITTER_USERNAME_URL );
        service.signRequest( accessToken, request );
        Response response = request.send();
        userName = Helper.extractJsonStringField( response.getBody(), "name" );
    }
    catch ( Exception e )
    {
        Helper.debug( "Error while obtaining twitter access token : " + e.getMessage() );
    }
    boolean success = null != accessToken;
    return new TwitterAuthDoneEvent( success, accessToken, userName, null, AuthType.ACCESS );
}
 
开发者ID:iTwenty,项目名称:Hashtagger,代码行数:28,代码来源:TwitterService.java

示例12: doAuth

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
@Override
protected void doAuth( Intent intent )
{
    final String code = intent.getStringExtra( SitesLoginHandler.VERIFIER_KEY );
    Token accessToken = null;
    String userName = null;
    try
    {
        OAuthService service = new ServiceBuilder()
                .callback( FacebookLoginActivity.FACEBOOK_CALLBACK_URL )
                .provider( FacebookApi.class )
                .apiKey( FacebookConfig.FACEBOOK_OAUTH_APP_ID )
                .apiSecret( FacebookConfig.FACEBOOK_OAUTH_APP_SECRET )
                .build();
        accessToken = service.getAccessToken( null, new Verifier( code ) );
        OAuthRequest request = new OAuthRequest( Verb.GET, FACEBOOK_USERNAME_URL );
        service.signRequest( accessToken, request );
        Response response = request.send();
        userName = Helper.extractJsonStringField( response.getBody(), "name" );
    }
    catch ( Exception e )
    {
        Helper.debug( "Failed to get Facebook access token : " + e.getMessage() );
    }
    boolean success = null != accessToken;
    // Subscriber : FacebookLoginHandler : onFacebookAuthDone()
    HashtaggerApp.bus.post( new FacebookAuthDoneEvent( success, accessToken, userName ) );
}
 
开发者ID:iTwenty,项目名称:Hashtagger,代码行数:29,代码来源:FacebookService.java

示例13: doAuth

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
@Override
protected void doAuth( Intent authIntent )
{
    final String code = authIntent.getStringExtra( SitesLoginHandler.VERIFIER_KEY );
    Token accessToken = null;
    String userName = null;
    try
    {
        OAuthService service = new ServiceBuilder()
                .provider( Google2Api.class )
                .callback( GPlusLoginActivity.GPLUS_CALLBACK_URL )
                .apiKey( GPlusConfig.GPLUS_OAUTH_CLIENT_ID )
                .apiSecret( GPlusConfig.GPLUS_OAUTH_CLIENT_SECRET )
                .scope( GPlusConfig.GPLUS_ACCESS_SCOPE )
                .build();
        accessToken = service.getAccessToken( null, new Verifier( code ) );
        OAuthRequest request = new OAuthRequest( Verb.GET, GPLUS_USERNAME_URL );
        service.signRequest( accessToken, request );
        Response response = request.send();
        userName = Helper.extractJsonStringField( response.getBody(), "displayName" );
    }
    catch ( Exception e )
    {
        Helper.debug( "Error while obtaining Google+ access token : " + e.getMessage() );
    }
    boolean success = null != accessToken;
    // Subscriber : GPlusLoginHandler : onGPlusAuthDone()
    HashtaggerApp.bus.post( new GPlusAuthDoneEvent( success, accessToken, userName ) );
}
 
开发者ID:iTwenty,项目名称:Hashtagger,代码行数:30,代码来源:GPlusService.java

示例14: authorize

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
@Test
@Ignore("Not suitable as automatic unit test. Requires manual action.")
public void authorize() throws URISyntaxException, IOException {
    final String key = System.getProperty("key");
    final String secret = System.getProperty("secret");
    assertNotNull("You must use a discogs key via System property -Dkey=", key);
    assertNotNull("You must use a discogs secret via System property -Dsecret=", secret);
    assertNotNull("You must use a custom user agent via System property -Dhttp.agent=", System.getProperty("http.agent"));
    final OAuthService service = new ServiceBuilder()
            .provider(DiscogsApi.class)
            .apiKey(key)
            .apiSecret(secret)
            .debug()
            .build();
    final Token requestToken = service.getRequestToken();
    System.out.println("Token: " + requestToken);
    final String authorizationUrl = service.getAuthorizationUrl(requestToken);
    System.out.println("AuthorizationUrl: " + authorizationUrl);

    Desktop.getDesktop().browse(new URI(authorizationUrl));
    System.out.println("Please enter token: ");
    final String token = System.console().readLine();
    System.out.println("Got " + token);
    final Verifier verifier = new Verifier(token);

    // Trade the Request Token and Verifier for the Access Token
    final Token accessToken = service.getAccessToken(requestToken, verifier);

    final OAuthRequest request = new OAuthRequest(Verb.GET, "https://api.discogs.com/image/R-944131-1175701834.jpeg");
    service.signRequest(accessToken, request);
    final Response response = request.send();
    System.out.println(response.getCode() + " " + response.getMessage());
}
 
开发者ID:hendriks73,项目名称:coxy,代码行数:34,代码来源:DiscogsApiTest.java

示例15: logActivity

import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
public void logActivity(long start_time, long duration, float distance, float calories) throws Exception
{
    log.info("Recroding: duration=" + duration / 1000l + "s, avg. distance=" + distance + "MPH, calories="
            + calories);

    if(token == null)
        throw new Exception("Must log in first to log activity");

    OAuthService service = new ServiceBuilder().provider(FitbitApi.class).apiKey(fITBIT_API_KEY).apiSecret(FITBIT_API_SECRET)
            .build();

    Date date = new Date(start_time);
    double roundedDist = BigDecimal.valueOf(distance / 1000).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();

    OAuthRequest request = new OAuthRequest(Verb.POST, ACTIVITY_ADD_URL);

    request.addQuerystringParameter("activityName", ACTIVITY_NAME);
    request.addQuerystringParameter("manualCalories", "" + Math.round(calories));
    request.addQuerystringParameter("startTime", TIME_FORMAT.format(date));
    request.addQuerystringParameter("durationMillis", "" + duration);
    request.addQuerystringParameter("distance", "" + roundedDist);
    request.addQuerystringParameter("date", DATE_FORMAT.format(date));

    service.signRequest(token, request);
    Response response = request.send();
    if(!response.isSuccessful())
    {
        log.log(Level.SEVERE, "FitBit API Error: " + response.getMessage());
        log.fine(response.getBody());
        throw new Exception("FitBit API Error: " + response.getMessage());
    }
}
 
开发者ID:vzaliva,项目名称:BikeDashboard,代码行数:33,代码来源:FitBitHelper.java


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