Sample vertx web application to showcase the usage of vertx-boot library.
Git clone the project on your local machine and import it to your favorite ide.
For runnning this, you will need
- Java 1.8
- Gradle support - In Eclipse editor, goto help -> eclipse marketplace -> search for buildship (buildship gradle integration) and install it.
- Vertx-Boot library.
This sample application make use of Vertx-Boot library to expose a rest API /runner/api/ping
- HttpServerVerticle -> Default verticle from the vertx-boot library. Can be extened for the functionality.
- MessagingVerticle -> Sample Messaging verticle to send messages (no functionality for now).
- ServerStatusHandler -> Sample handler to send a "OK" Json response.
- PingHandler -> Default handler from the vertx-boot library to send a "OK" Json response.
For running the app, (IDE used here is IntelliJ)
- Open appConfig.json file and set the "http_server_port" as per your choice.
- Once, changes are done in appConfig.json, add/edit Run/Debug Configurations for the project("vertx-social") and set:
- Main class: com.greyseal.vertx.boot.AppLauncher
- VM options: -Dlogback.configurationFile=file:../vertx-social/src/main/resources/logback.xml
- Program arguments: run com.greyseal.vertx.boot.verticle.MainVerticle -conf ../vertx-social/src/main/resources/appConfig.json
- Environment variables: ENV=dev
After setting the variables, Run/Debug the project. If app starts successfully, then try
Type: GET http://localhost:8080/runner/api/ping
Headers: Content-Type: application/json; Trace-Id: c1d887063c3e492b9951b0479fadddda
Response
{
"status": "OK"
}
That's it.
- Currently added support for LinkedIn/Github apis. To run/debug...
- To get Authorization url
Type: POST http://localhost:8080/runner/api/social/authorizationurl?provider=LINKEDIN
Headers: Content-Type: application/json; Trace-Id: c1d887063c3e492b9951b0479faddddu
Request body:
{
"scopes": [
"r_basicprofile",
"r_emailaddress",
"rw_company_admin",
"w_share"
],
"redirect_uri": "{redirect_uri}",
"state": "STATE"
}
Response:
{
"authorizationURL": "{authorization_url}"
}
Click on Authorization url to get the Authorization code.
- To get Access Token url
Type: POST http://localhost:8080/runner/api/social/accesstoken?provider=LINKEDIN
Headers: Content-Type: application/json; Trace-Id: c1d887063c3e492b9951b0479faddddu
Request body:
{
"code":"{authorization_code}",
"redirect_uri":"{redirect_uri}"
}
Response:
{
"access_token": "{access_token}",
"expires_in": 5163999,
"expires_at": 1561910752077
}
Get the access_token and pass it to the concrete apis
- To get Linkedin user profile url
Type: POST http://localhost:8080/runner/api/social/profile?provider=LINKEDIN
Headers: Content-Type: application/json; Trace-Id: c1d887063c3e492b9951b0479faddddu
Request body:
{
"access_token":"{access_token}"
}
Response:
{
"firstName": "ABC",
"headline": "Software Engineer",
"id": "8mAy5C1epf",
"lastName": "XYZ",
"siteStandardProfileRequest": {
"url": "{url}"
}
}
Try same for Github by updating provider=LINKEDIN t0 provider=GITHUB