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


Java WebClient.postAbs方法代码示例

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


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

示例1: testImplicitMode

import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
public void testImplicitMode() {
    vertx = Vertx.vertx();
    WebClient client = WebClient.create(vertx);
    HttpRequest<Buffer> request = client.postAbs("http://admin:[email protected]:8080/oauth/authorize?response_type=token&scope=read%20write&client_id=myClientId&redirect_uri=http://example.com");
    request.putHeader("Authorization", getHeader());
    request.send(ar -> {
        if (ar.succeeded()) {
            HttpResponse<Buffer> response = ar.result();
            //String location = response.getHeader("Location");
            String body = response.bodyAsString();
            System.out.println("Implicit Mode Get Token" + body + " status code" + response.statusCode() + " Location=");
        } else {
            System.out.println("Something went wrong " + ar.cause().getMessage());
        }
    });
}
 
开发者ID:openmg,项目名称:metagraph-auth,代码行数:17,代码来源:VertxWebTest.java

示例2: testPasswordMode

import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
public void testPasswordMode() {
    vertx = Vertx.vertx();
    WebClient client = WebClient.create(vertx);
    HttpRequest<Buffer> request = client.postAbs("http://localhost:8080/oauth/token?client_id=myClientId&client_secret=myClientSecret&grant_type=password&username=admin&password=admin");
    request.send(ar -> {
        if (ar.succeeded()) {
            HttpResponse<Buffer> response = ar.result();
            JsonObject body = response.bodyAsJsonObject();
            System.out.println("Password Mode Get Token" + body + " status code" + response.statusCode());
        } else {
            System.out.println("Something went wrong " + ar.cause().getMessage());
        }
    });
}
 
开发者ID:openmg,项目名称:metagraph-auth,代码行数:15,代码来源:VertxWebTest.java

示例3: testClientMode

import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
public void testClientMode() {
    vertx = Vertx.vertx();
    WebClient client = WebClient.create(vertx);
    HttpRequest<Buffer> request = client.postAbs("http://localhost:8080/oauth/token?client_id=myClientId&client_secret=myClientSecret&grant_type=client_credentials&scope=read%20write");
    request.send(ar -> {
        if (ar.succeeded()) {
            HttpResponse<Buffer> response = ar.result();
            JsonObject body = response.bodyAsJsonObject();
            System.out.println("Client Mode Get Token" + body + " status code" + response.statusCode());
        } else {
            System.out.println("Something went wrong " + ar.cause().getMessage());
        }
    });
}
 
开发者ID:openmg,项目名称:metagraph-auth,代码行数:15,代码来源:VertxWebTest.java

示例4: testAuthorizationCode

import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
public void testAuthorizationCode() {
    vertx = Vertx.vertx();
    WebClient client = WebClient.create(vertx);
    HttpRequest<Buffer> request = client.postAbs("http://admin:[email protected]:8080/oauth/authorize?client_id=myClientId&client_secret=myClientSecret&redirect_uri=http://example.com&response_type=code&scope=read%20write");
    request.putHeader("Authorization", getHeader());
    request.send(ar -> {
        if (ar.succeeded()) {
            HttpResponse<Buffer> response = ar.result();
            String body = response.bodyAsString();
            System.out.println("Authorization Code Mode Get Token" + body + " status code" + response.statusCode());
        } else {
            System.out.println("Something went wrong " + ar.cause().getMessage());
        }
    });
}
 
开发者ID:openmg,项目名称:metagraph-auth,代码行数:16,代码来源:VertxWebTest.java

示例5: testAuthorizationCodeMode

import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
public void testAuthorizationCodeMode() {
    Vertx vertx = Vertx.vertx();
    OAuth2Auth oauth2 = OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions()
            .setClientID("myClientId")
            .setClientSecret("myClientSecret")
            .setSite("http://localhost:8080")
            .setTokenPath("/oauth/access_token")
            .setAuthorizationPath("/oauth/authorize")
    );

    // when there is a need to access a protected resource or call a protected method,
    // call the authZ url for a challenge

    String authorization_uri = oauth2.authorizeURL(new JsonObject()
            .put("redirect_uri", "http://localhost:8080/secure")
            .put("scope", "read"));

    WebClient client = WebClient.create(vertx);
    HttpRequest<Buffer> request = client.postAbs(authorization_uri);
    request.putHeader("Authorization", getHeader());
    request.send(ar -> {
        if (ar.succeeded()) {
            HttpResponse<Buffer> response = ar.result();
            String body = response.bodyAsString();
            System.out.println("Authorization Code Mode Get Token" + body + " status code" + response.statusCode());

            //.put("state", "3(#0/!~"));
            // when working with web application use the above string as a redirect url
            // in this case GitHub will call you back in the callback uri one should now complete the handshake as:
            /*String code = "xxxxxxxxxxxxxxxxxxxxxxxx"; // the code is provided as a url parameter by github callback call
            oauth2.getToken(new JsonObject().put("code", code).put("redirect_uri", "http://localhost:8080/secure"), res -> {
                if (res.failed()) {
                    // error, the code provided is not valid
                } else {
                    // save the token and continue...
                    System.out.println("AuthorizationCode Mode Get Token Info= " + res.result().toString());
                }
            });*/

        } else {
            System.out.println("Something went wrong " + ar.cause().getMessage());
        }
    });


}
 
开发者ID:openmg,项目名称:metagraph-auth,代码行数:47,代码来源:VertxOAuth2ClientTest.java


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