Contributions
Re: OATH2 Authentication - can "get ID Token" be automated in testing?
Found a solution from SmartBear. Posting to help others. Here is the reply... worked perfectly for me. Put this code into a groovy step. I had to modify the profileName retrieval line but it worked exactly as-is otherwise. -------------- Begin Code snippet ---------------- import com.eviware.soapui.support.editor.inspectors.auth.TokenType import com.eviware.soapui.impl.rest.actions.oauth.OltuOAuth2ClientFacade def authContainer = testRunner.testCase.testSuite.project.OAuth2ProfileContainer // Get OAuth2 profile name def profileName = context.expand( '${#Project#profileName}' ) def authProfile = authContainer.getProfileByName(profileName) def clientFacade = new OltuOAuth2ClientFacade(TokenType.ID) //TokenType.ID gets the ID token clientFacade.requestAccessToken(authProfile, true) def accessToken = authProfile.getAccessToken() ------------------- End code snippet ----------------------- Additionally, there is this for just the access token (From SmartBear): You can get the access token by using the Groovy script above and replacing def clientFacade = new OltuOAuth2ClientFacade(TokenType.ID) with def clientFacade = new OltuOAuth2ClientFacade(TokenType BEARER) to get the access token instead of the id token.8 years agoPlace ReadyAPI QuestionsReadyAPI Questions5.3KViews1like5CommentsAutomate 'Get ID Token" on the Authorization Profile for OATH2 authentication.
Oath2 authentication already has the ability to automate retrieval of an access token if needed on a step that uses oath2 authentication. We need something similar for the ID Token. The two are retrieved at the same time but the authorization automation only auto populates/refreshes the access token. To obtain a valid ID Token, you must go to the authorization profile, select 'get ID Token" followed by selecting 'get OpenID Token' on the subsequent popup. At this point your authorization profile has a valid idtoken to use. Since we have to have a valid id token, there is a manual step to an otherwise automated set of project test suites... the tester must manually go and fetch an id token at the beginning of running the test suites.1.5KViews0likes0CommentsOATH2 Authentication - can "get ID Token" be automated in testing?
I have oath2 authentication configured and have setup correct automation scripts. It works perfectly for setting up the access token. Furthermore, I can access this token within a groovy script by the following: 1) def authEntry = context.getCurrentStep().testCase.testSuite.project.getAuthRepository().getEntry("myProfile"); 2) authEntry.getAccessToken() The problem I have is that I also need the ID Token. So, for the above code, "authEntry.getIdToken()" will not return a value unless I go to the authorization tab on a rest test step and manually click on the "get ID Token" button. Once I manually click on this button, the ID Token will be available in the authentication repository object for "myProfile", and calling "authEntry.getIdToken()" returns the expected value. From what I can tell, this is not automated. Is there something I'm missing for automaticallypopulation of the authorization profile's ID Token attribute?Solved8 years agoPlace ReadyAPI QuestionsReadyAPI Questions5.5KViews0likes8Comments