Forum Discussion

Preerab's avatar
Occasional Contributor
6 years ago

how to automate our manual Oauth2.0 process. ?


I am trying to automate token retrival part of my REST URI call. I am successful in generating OAUTH2.0 (client crential) token manually 'Get Token'

I am following Javascript and Groovy scripts


Under Page 1: I got Java script for Authorization.

try adding consent screen in Page 2

I tried Groovy script in Page 3 (whcih suppose to retrive token if its expired) 

Getting below error on Page 3



The following script is invalid: // Import the required classes import; import; import; // Set up variables def project = ModelSupport.getModelItemProject(context.getModelItem()); def authProfile = project.getAuthRepository().getEntry("OAuth 2"); def oldToken = authProfile.getAccessToken(); def tokenType = TokenType.ACCESS; // Create a facade object def oAuthFacade = new OltuOAuth2ClientFacade(tokenType); // Request an access token in headless mode oAuthFacade.requestAccessToken(authProfile, true, true); // Wait until the access token gets updated while(oldToken == authProfile.getAccessToken()) { } //The sleep method can be used instead of a while loop //sleep(3000); // Post the info to the log"Set new token: " + authProfile.getAccessToken()); Error: missing ; before statement (scriptToValidate#2)




Attached screen shot.

I am sure, something silly I am missing. Appreciate help


8 Replies