So how this can be addressed is two fold api call . so basically Oauth is another api call which fetches bearer token in return.
What I suggest is create a rest for that and store the bearer token in node level data page.
Secondly when you do the actual endpoint REST call pass it under auth headers tag it should work fine.
I faced the same when consuming google API’s did the same it does’nt refresh when you configure automatically using auth profile.. Be sure to flush data page based on token expiration which will be part of the initial token response generally its 3600 seconds or 1hr just check it.
Try it am absolutely sure it will worked I used it for Google Fitness API.
This is a known issue in Pega, actually the refresh token is not persisted in Data-Admin-Security-OAuth2-AccessToken and for this reason we face the issue.
Alternatively we have created a separate REST connector to retrieve the access token using refresh token and we managed to store the refresh token in a DSS rule. Use the same refresh token to generate the bearer token. Once you get the bearer token use it into your first integration to suffice the requirement.
Just a point to remember for the first invocation the grant_type will be authorization_code and from the next time it will be refresh_token.