How to get access token dynamically using code

Can you help me on this how can i capture transit URL info?. really want to wind up the automation manual token info generation.

Hi @gopabandhu.patra,
Instead of using WebUI.getUrl(), can you try WebUI.executeJavaScript(‘return window.document.referrer’, null) to get the immediate URL?‘Object Repository/Page_Sign In/span_Sign in’))

String redirectUrl=WebUI.executeJavaScript(“return window.document.referrer;”, null)

println “ORIGINAL…”+redirectUrl

Did it but it is not capturing transit URL…

Any response please??

Hi @gopabandhu.patra,
Can you share a video that capture the automation process to login for OAuth2 access token? (3.3 MB)
here you go

any response please?

Hi @gopabandhu.patra,
I suspect that the developers of your site may store some valuable information in the cookies. You should perform the steps to login again and when the last page shows up, please inspect the site cookies to see if there is something that helps.

I can see the token while inspecting and can collect manually. How can i collect that element/value from katalon?

Hi @gopabandhu.patra,
You mean that you see the token from the cookies?

Here you see i can see the token… How can i get this from katalon?

Hi @gopabandhu.patra,
In the automation code, can you invoke DriverFactory.getWebDriver().manage().getCookies() and share the String representation of the cookies?

[_gat=1; expires=Tue, 11 Aug 2020 02:23:13 SGT; path=/;, _ga=GA1.2.2049607677.1597126934; expires=Thu, 11 Aug 2022
02:22:13 SGT; path=/;, ai_user=pLVEt|2020-08-11T06:22:13.931Z; expires=Wed, 11 Aug 2021 02:22:13 SGT;
path=/;;secure;, ai_session=va3k/|1597126933934.02|1597126933934.02;
expires=Tue, 11 Aug 2020 02:52:13 SGT; path=/;;secure;,
ARRAffinity=1ae70d8f3a94ece05432e731b2706b3e697429b7036c866aeece4fc215a521df; path=/;, G_ENABLED_IDPS=google; expires=Fri, 31 Dec 9999 08:00:00 SGT;
path=/;, _gid=GA1.2.1585004102.1597126934; expires=Wed, 12 Aug 2020 02:22:13 SGT; path=/;]

anything??? struggling

Hi @gopabandhu.patra,
I’m afraid that we cannot proceed with this solution, as there is no official method to get the intermediate URL with Selenium. Can you ask your developers if they support Refresh Token grant type, and if yes, how long that refresh token is valid? If we have that information, maybe we will try another way.

How can postman get the information by giving Implicit grant type?

Hi @gopabandhu.patra,
Can you share a video how you get an access token with Postman?

pfa… (1.9 MB) pfa is the steps postman follows

Hi @gopabandhu.patra,
I have attached new version of the project I sent last time. In this version, I use Selenium WebDriverWait to help capture the intermediate URL. Remember that you have to set the pageLoadStrategy to “none” in Desired Capabilities settings, and the browser you use should be Chrome. (64.1 KB)

Many thanks… got it the token…

1 Like