Reputation: 21
How to start the oauth2 token retrieval at the beginning of the script, automatically without clicking on the "Get Token"?
Upvotes: 0
Views: 2163
Reputation: 21
I have found the groovy script to launch the oauth2 get token:
import com.eviware.soapui.impl.rest.actions.oauth.OltuOAuth2ClientFacade
def authContainer = testRunner.testCase.testSuite.project.OAuth2ProfileContainer
// Get OAuth2 profile name
def profileName = context.expand("Oauth2")
def authProfile = authContainer.getProfileByName(profileName)
def clientFacade = new OltuOAuth2ClientFacade()
clientFacade.requestAccessToken(authProfile)
//To get the access token
def accessToken = authProfile.getAccessToken()
Upvotes: 1