Updating Oauth credentials

Tony Chatfield1
Kilo Patron

I’m currently implementing a rest integration using OAuth2

The resource owner response (for a token) is not processed OOB and there is a slightly tweaked version of OAuthUtil postprocessAccessToken() which resolves the response compatibility issue.

If I trigger authentication via UI action ‘Get OAuth Token’, the access and refresh tokens are renewed and the details updated into ‘oauth_credential’ table. But if I trigger authentication via a script call for oAuthClient.requestToken, the access and refresh tokens are correctly returned but ‘oauth_credential’ is not updated with the new access or refresh tokens (regardless of scope)

So my version of OAuthUtil is functional, otherwise the UI action would not result in populated credentials,  but I cannot see why there is no update to ‘oauth_credential’  when authentication is via a script and I haven’t been able to find any information that indicates if this is correct\expected behavior and\or if I need to include additional functions in my script

I can push an update into ‘oauth_credential’ using Glide, but wanted to check first in-case I had missed something.

Should I expect my existing token records in ‘oauth_credential’ to be updated, when I authenticate via a script?
Have I missed something obvious?

Appreciate any thoughts
Tony

My script is simply
var oAuthClient = new sn_auth.GlideOAuthClient();
var params = {grant_type:"password", userStuff, passwordStuff};
var json = new global.JSON();
var text = json.encode(params);
var tokenResponse = oAuthClient.requestToken('myOAuthRecord’, text);

1 ACCEPTED SOLUTION

Tony Chatfield1
Kilo Patron

Taking another look and following the UI authentication process through, the function required is 'requestTokenByRequest'

Some context can be found here
/nav_to.do?uri=sys_script_include.do?sys_id=b77f2ee28f20020026935f2a37bdeef3

Using this approach, 'oauth_credential' is updated with the new token details.

View solution in original post

1 REPLY 1

Tony Chatfield1
Kilo Patron

Taking another look and following the UI authentication process through, the function required is 'requestTokenByRequest'

Some context can be found here
/nav_to.do?uri=sys_script_include.do?sys_id=b77f2ee28f20020026935f2a37bdeef3

Using this approach, 'oauth_credential' is updated with the new token details.