There is a bank service that provides API to do some operations with bank accounts. To perform a request to all endpoints of this service I, first of all, need to get auth token via grand_type=auth_code; I can easily get the auth code and then access token manually. When browser redirects me to bank auth page I just enter my credentials and then It redirects me to my predefined URL with auth_code.

But I need to write unit tests for my implementation of this API. And how can I perform this process with entering credentials and send request from the page programmatically to get auth code?


You can try to use Selenium WebDriver to automate the flow.

I recently did exactly that - automated integration tests calling bank API protected by OAuth and it took me only few hours to get it to work.

Basically You run a real browser and drive interaction with web page from Java code replicating manual interaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.