I have read many articles addressing my current issue but none of the article's/thread's solutions resolved my problem.
I'm using SoapUI 5.5.0 (free version) and attempting to retrieve an OAuth2 Access Token from a vendor's API using the Get Token feature in the Authorization section of my request. I created a Profile and assigned the following configuration for the profile:
- OAuth2 Flow: Client Credentials Grant
- Client Identification: our-client-id
- Client Secret: our-client-secret
- Access Token URI: baseURL-provided-by-the-vendor/oauth
- Scope: empty
I click the "Get Access Token" button and SoapUI throws an error alert "Could not retrieve access token. Check the SoapUI log for details"
The SoapUI log shows the following (abbreviated):
Tue Jun 16 09:57:51 CDT 2020:ERROR:Error retrieving OAuth 2 access token **Tue Jun 16 09:57:51 CDT 2020:ERROR:com.eviware.soapui.impl.rest.actions.oauth.OAuth2Exception: org.apache.oltu.oauth2.common.exception.OAuthSystemException: OAuthProblemException{error='invalid_request', description='Missing parameters: access_token', uri='null', state='null', scope='null', redirectUri='null', responseStatus=0, parameters={}} **
Based on this error, I conducted fairly exhaustive research (on this site and others) and located alternative methods involving accessing the token directly from one of my groovy scripts. I attempted to run the following suggested method in a groovy script:
import com.eviware.soapui.impl.rest.actions.oauth.OltuOAuth2ClientFacade
def authContainer = testRunner.testCase.testSuite.project.OAuth2ProfileContainer
def profileName = "Automation"
def authProfile = authContainer.getProfileByName(profileName)
def clientFacade = new OltuOAuth2ClientFacade()
clientFacade.requestAccessToken(authProfile)
//To get the access token
def accessToken = authProfile.getAccessToken()
When I execute this script, I get the following error:
com.eviware.soapui.impl.rest.actions.oauth.OAuth2Exception: org.apache.oltu.oauth2.common.exception.OAuthSystemException: OAuthProblemException{error='invalid_request', description='Missing parameters: access_token', uri='null', state='null', scope='null', redirectUri='null', responseStatus=0, parameters={}} error at line: 8
It has a problem with the method call clientFacade.requestAccessToken(authProfile).
Note that, while in Postman, I can request an Access Token from the exact same URL, using the exact same Flow type, with the same client credentials, with no scope provided, and retrieve the token with no errors at all.
For now, I am forced to manually retrieve the token using Postman, then paste it into the Access Token field in SoapUI, which is not ideal. I'd really like to be able to automate this in SoapUI. Any suggestions would be great. Thanks!