OAuth token via Basic Auth
Now, let's explore and implement a short example of using tokens. In order to build this example, we will create a class. This class, as in the previous example, will simulate a database client. It will have the same method, getCompactDiscs()
, but we will modify the internal function in this example. Also, it won't receive any parameter this time.
Alright, let's do it! First, create two static string fields in the class. The first field will hold the URL for authentication in the auth-server. The other field will have the URL showing the compact discs list; you can reuse the same web page from the previous example. Then, you should have your variables as shown:
private static String urlAuth = "https://localhost:8443/auth-server ...
Get RESTful Java Web Services Security now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.