Yes, this is very possible - typically whatever can be done in the browser can be scripted somehow, or there are features in PingFederate designed for retrieve an OAuth token without browser interaction altogether if that's your ultimate goal.
For example you could use OAuth resource owner password credentials grant to simply pass a user's username & password to the token endpoint and get it back. See: https://support.pingidentity.com/s/document-item?bundleId=pingfederate-93&topicId=lzn1564003025072.html
But it's not clear to me from your description what the exact requirements are. Please reach out to us (Ping Identity - my employer), and our support team would be happy to work through all the details with you: https://support.pingidentity.com/