You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

OAuth2 Refresh Token Request not working from EPM Groovy Script

Received Response
41
Views
4
Comments

Summary: We are facing issue while calling Rest API to generate an OAuth2 token using EPM Groovy script. I am trying to run the following code, but if I try same step in postman it is working fine



1. Step -1 Get Device code (Is working Fine)


Code :


String payload = 'response_type=device_code&scope=urn%3Aopc%3Aidm%3A__myscopes__%20offline_access&client_id=<Clinet ID>'

def headers = ['Content-Type': 'application/x-www-form-urlencoded']

HttpResponse<String> jsonResponse = operation.application.getConnection("OAuth2").post('/oauth2/v1/device').headers(headers).body(payload).asString()

println ("Response: $jsonResponse.body")



OutPut:

Response: {"device_code":"<Device Code>","user_code":"TTFHX","verification_uri":"

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!