vert-x3 / vertx-examples

Vert.x examples
Apache License 2.0
3.55k stars 2.09k forks source link

Added examples for OAuth2WebClient #462

Closed pendula95 closed 3 weeks ago

pendula95 commented 3 weeks ago

Example of using OAuth2WebClient to send requests to protected server.

This can also be used as replacement for Twitter Example as it demonstrates the same thing but uses local resources that are present and does not require additional setup/accounts/tokens.

I wrote everything inside one class unlike rest of the examples in web client as I find it easier to run.

I did not edit https://github.com/vert-x3/vertx-examples/blob/5.x/web-client-examples/README.adoc as I want to wait first for the decision if Twitter Example should be removed and if it is ok to keep both server and client in one class.

This is in reference with #460

vietj commented 3 weeks ago

@pendula95 can you rebase on latest 5.x ?

pendula95 commented 3 weeks ago

@pendula95 can you rebase on latest 5.x ?

Done but it looks like the specific testcontainer dependency requires java 17 or higher which creates the issue as vert.x min version is 8 if I am not mistaken. I will need to find an alternative

vietj commented 3 weeks ago

are we good to merge @pendula95 ?

pendula95 commented 3 weeks ago

are we good to merge @pendula95 ?

I added this example as I looked at #460 and saw that Twitter example needed refresh. I noticed that the Twitter example used raw token management as it was probably written before OAuth2Aware Web Client was introduced. So instead of using Twitter example which requires having an account/api key for twitter I made an example with local resources using test containers.

It is not still not read as https://github.com/vert-x3/vertx-examples/blob/5.x/web-client-examples/README.adoc was not modified to include this example with brief explanation.

To sum it up (we should decide what to do): 1) Keep Twitter Example as is and add this one as addition.
2) Remove Twitter example as this one covers same thing but with different approach. 3) Keep this one as it shows how to do it with Keycloak but also update Twitter one to use session aware client as it is a recommended way.

vietj commented 3 weeks ago

@pendula95 we are going to keep the twitter example as it is actually fine

vietj commented 3 weeks ago

can you provide a PR for the README ?