EXTRACT VALUE FROM PAGE URL - Google OAuth 2

I am working on setting up a 3 step API call to request Google refresh token. In order for that to happen, the end user must be redirected to an website external website where the user need to log in with their google account. Then, Use the returned google code in the returned page URL to be the first parameter used in Step 1 of the API. Then, the returned data of API 1 will be used to initialize the second API.

The process looks like that

      • Step 1 : Redirect user to this external website something like this

    1. Once logged in with google, the user is redirected back to my website with a page URL that looks like that

https:// ssm9225 .preview. drapcode. io/dashboard?code=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXXXX&scope=email+profile+https%3A%2F%2Fwww. googleapis. com%2Fauth%2Fyoutubepartner+https%3A%2F%2Fwww. googleapis .com%2Fauth%2Fuserinfo.email+openid+https%3A%2F%2Fwww. googleapis. com%2Fauth%2Fuserinfo.profile&authuser=0&prompt=none

    1. The Code value in the page URL will be needed to initialize the first API

My question is how to extract the code value from the page URL ??

Please help

1 Like

Hi @Gharaibehr,

I am not 100% sure if there is a readymade way to do it. The easies way would be to write a few lines of Javascript code which will take this parameter value from the URL on page load and set it in the session or hidden field, which then can be used to pass to the next API.

Let me know if you need any help in writing that JS code, will be happy to do that.

Thanks.