Best Approach to Handle and Store OAuth Authorization Code in ServiceNow

Pooja_29
Tera Contributor

Hello everyone,

I am currently working on integrating ServiceNow with LinkedIn. As part of the OAuth 2.0 authorization flow, after users successfully authorize the integration, I receive an authorization code in the URL, like this:

 

 

https://dev203650.service-now.com/oauth_redirect.do?code=AQR_WjTIXSyvTCy8Aa1dKJRHBY0WB8RiWezj03AESdnLtrmtW5I4eTr_pNzqHduw-Qfb8c4cE4tdJhqeb3O7-7fR0eMYFfEmklHmlKYbimmg4YC0p_JlS4AaHkVYnXKu8lWl8W_mjew-JD45gLA1JyEdQZhpEwz-h7FJBmQfrEJ6i4DUo7mhJy3fOmTk3G6St0J_puLG4HDOEyT_SZ0

 

I would like to understand the best approach to handle and store this authorization code in ServiceNow for obtaining access tokens for multiple users. Specifically, I am looking for guidance on how to capture the code from the redirect URL and securely store it in ServiceNow for further processing.

5 REPLIES 5

Runjay Patel
Giga Sage

HI @Pooja_29 ,

 

Best way to do is to store it in property.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Hi @Runjay Patel ,
Can you explain in detail how I can store this code?

Hi @Pooja_29 ,

 

Create a property to store the same and use 

 

gs.setProperty('property_name', 'property_value');

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Hi @Runjay Patel,

Actually, the authorization in this URL is dynamic and changes continuously