Forum Discussion

adip01's avatar
adip01
New Contributor
7 years ago
Solved

SOAPUI auth2 accessToken automatic refresh

Hello,

First of all please accept my apologies if this topic has been already discussed & solved, but believe me I looked everywhere before creating a new ticket.

 

Coming back to my problem, I am using the SoapUi open source to write functional tests for REST APIs; in order to have have valid requests I have to pass for each of available requests the Oauth 2 bearerToken, so I've created a profile at the project side, checked the automatic refresh option (for the accessToken) and then re-used the same profile for all the tests within my project.

 

Current issue: all the daily tests are failing to be executed - they are executed from command line and scheduled in a continuous environment - due to the token's expiration; it seems that SOAPUI does not know to automatically refresh the token, even if I checked the option when the profile has been defined.

Is this the expected behavior? I hope not, but if indeed it is, then please advice me upon the best to solve it in order to have the automatic refresh being done - I was thinking to create a script in order to obtain the token (retrieve it from server) and the to add it as setup script per test case? Could you please advice me in other directions, maybe with some examples? (I am a really novice in therm of groovy scripting :(  ).

 

Many thanks in advance!

 

  • Hello to all,

    Finally i managed to solve the issue, though i did not manage to really understand why SoapUi behaves in such a way :)

    The solution would be to add the following syntax within the SOAPUI .xml project file, as part of the Auth2 profile's definition, just before the <con:resourceOwnerName>:

    <con:javaScripts>
    <con:entry/>
    <con:entry/>
    </con:javaScripts>

     

    Do not forget, in my situation i am using Oauth2 authentication with ResourceOwnerClientCredentials flow. i did not check this solution for other auth flows.

    I really hope this will help you all! For me it was such a pain till I managed to find the fix for it.

    Luckily for more than 2 weeks my tests are executed each morning and the token's auto-refresh works like a charm.

     

1 Reply

  • adip01's avatar
    adip01
    New Contributor

    Hello to all,

    Finally i managed to solve the issue, though i did not manage to really understand why SoapUi behaves in such a way :)

    The solution would be to add the following syntax within the SOAPUI .xml project file, as part of the Auth2 profile's definition, just before the <con:resourceOwnerName>:

    <con:javaScripts>
    <con:entry/>
    <con:entry/>
    </con:javaScripts>

     

    Do not forget, in my situation i am using Oauth2 authentication with ResourceOwnerClientCredentials flow. i did not check this solution for other auth flows.

    I really hope this will help you all! For me it was such a pain till I managed to find the fix for it.

    Luckily for more than 2 weeks my tests are executed each morning and the token's auto-refresh works like a charm.