The CreatorCon Call for Content is officially open! Get started here.

Using Outbound OAuth in an App - how to handle different redirect urls of the target instance?

Utopia
Tera Contributor

When I create a ServiceNow App which uses OAuth to access a REST service, I do not know the redirect URL of the ServiceNow target instance in advance. Wildcards are not allowed in external the OAuth Client.
Is there any method to handle this situation?
I'm pretty new to ServiceNow, so I possibly miss something here, because I assume this should be a common problem in the ServiceNow landscape.

Thanks for any advice!

1 REPLY 1

Tushar
Kilo Sage
Kilo Sage

Hi @Utopia 

 

I think you can try to use a temporary redirect URL.

This means that you would specify a redirect URL that you know will work, but then change it to the actual redirect URL once you know what it is.

To do this, you would need to use the setRedirectURL() method on the OAuthClient object.

For eg:

var oAuthClient = new OAuthClient();
oAuthClient.setRedirectURL('https://my-temporary-redirect-url.com');

Once you know the actual redirect URL, you can call the setRedirectURL() method again to change it.

 

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar