OAuth Application Registries Record Creation for Airtable

benm3
Mega Guru

Hi,

 

I am trying to create an OAuth access token for my Airtable integratoin and I am running into some issues. I have registered an integration on the Airtable website which has given me client ID, client secret and OAuth redirect URL. I have then created an Application Registries record in my SN instance with these values.

 

When I set the add the OAuth profile created to the rest message I have created and use the UI Action 'Get OAuth Token'. I recieve the following error in the url:

 

"error=invalid_request&error_description="state"+parameter+is+invalid.+Note+that+it+is+required.&state=-68948287"

 

I understand why I am getting this error as per the Airtable documentation I need a 'state' parameter, and a couple of other ones as well. However, I am not sure where the 'state' param goes? Is this set in the HTTP Headers or HTTP Query Prameters of the rest message?  (https://airtable.com/developers/web/api/oauth-reference).

 

Also once I generate this token, will the endpoint work as expected when I click test after passing in the correct params in the endpoint url?

 

Thanks for any help in advance, I have attached screenshots of the rest message and application registries record.

3 REPLIES 3

Ahmmed Ali
Mega Sage

You will need to extend the OAuthUtil script include and override the function interceptRequestParameters as stated in below KB article. Then use the new script include created as "OAuth API script" in your application registry.

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0792354

 

Thanks,

Ali 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

If you want to get the token from server script then https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0743846 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Hi, thanks for your help. I have extended the ootb script include and added in the required params but I am still receiving that error from before. I have also placed two logs within the script include and they do not seem to be appearing. Can you please check if I have done anything wrong?

 

Here is the extended script includes code:

var OAuthComplianceCommisionsUtils = Class.create();
OAuthComplianceCommisionsUtils.prototype = Object.extendsObject(global.OAuthUtil, {
	
	interceptRequestParameters : function(requestParamMap) {
		gs.info("interceptRequestParameters ben")
		// Add/Modify request parameters if needed
		requestParamMap.put('response_type','code');
		requestParamMap.put('scope','data.records:read');
		requestParamMap.put('state','Q5tSjh4nLJbz.-_K8fWkYp0wEiRDVcZxN9Xa1mO7v2u6Mqy3gArGsC');
		requestParamMap.put('code_challenge','w1q3qECN6T2g6bN8ncUqKN6KLvCZ4uV7l-BP6oWGG7w');
		requestParamMap.put('code_challenge_method','S246');
		this.preprocessAccessToken(requestParamMap);
	},
	
	preprocessAccessToken: function(requestParamMap) {
		gs.info("ben preprocessAccessToken");
	},
	
	type: 'OAuthComplianceCommisionsUtils'
});