Dynamically Set client credentials
I am trying to change the credentials by the groovy script but the below code line are not working in my soapui 5.7 tool
oAuthProfile.setOAuth2Flow(OAuth2FlowConfig.CLIENT_CREDENTIALS_GRANT)
Error : groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlProject.getAuthRepository() is applicable for argument types: () values: [] error at line: 6
my groovy script :
import com.eviware.soapui.impl.rest.actions.oauth.OltuOAuth2ClientFacade
import com.eviware.soapui.support.editor.inspectors.auth.TokenType
import com.eviware.soapui.config.OAuth2FlowConfig;
def project = context.getTestCase().getTestSuite().getProject();
def oAuthProfile = project.getAuthRepository().getEntry("Name of your OAuth profile");
//Client Credentials Grant
oAuthProfile.setOAuth2Flow(OAuth2FlowConfig.CLIENT_CREDENTIALS_GRANT)
oAuthProfile.setClientID("Identification");
oAuthProfile.setClientSecret("Secret");
oAuthProfile.setAccessTokenURI("TokenURI");
oAuthProfile.setScope("Scope");
oAuthProfile.setUseNonce(true);
oAuthProfile.setUseAuthHeader(true);
// getting the access token
def oAuthClientFacade = new OltuOAuth2ClientFacade(TokenType.ACCESS);
oAuthClientFacade.requestAccessToken(oAuthProfile, true, true); // profile, modalMode, consoleMode
//set the profile for a test step
def step = testRunner.testCase.getTestStepByName("Name of the Step").getHttpRequest();
step.setSelectedAuthProfile("Name of your OAuth profile");