Forum Discussion

baqri14's avatar
New Contributor
2 years ago

[Urgent] How to generate an report in SoapUI 5.7.0 (Free) with refresh access token?

1 Reply

  • baqri14's avatar
    New Contributor

    I have found the solution.


    This can be solved with the help of the Groovy script.


    // Import the required classes
    import;// Set up variablesdef authContainer = testRunner.testCase.testSuite.project.OAuth2ProfileContainer
    def authProfile = authContainer.getProfileByName("Profile 2")
    def oldToken = authProfile.getAccessToken();// Create a facade object
    def oAuthFacade = new OltuOAuth2ClientFacade();// Request an access token in headless mode
    oAuthFacade.requestAccessToken(authProfile);// Wait until the access token gets updated
    while(oldToken == authProfile.getAccessToken()) {
    }// Post the info to the log"Set new token: " + authProfile.getAccessToken());