Automating OAuth 2 authentication and consent

The Get Token OAuth 2 functionality in SoapUI has the ability to run JavaScript to automatically authenticate and grant permissions (consent) during the browser-based interaction with the Authorization Server. Assuming you're happy to provide your credentials to the script, this could be useful if unattended authentication is required for your tests. This recipe briefly shows how to do this for the previous Gmail example.

Getting ready

This recipe assumes you've completed the previous recipe. In any case, you can find the completed SoapUI project GoogleOAuth2 in the chapter 8 samples.

How to do it...

We just need to add the automation JavaScript to input credentials and submit on the first screen (login ...

Get SoapUI Cookbook 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.