While creating new credentials we want to be able to request & fetch OAuth2 tokens from our platform itself. Meaning the user would be using UI on our platform to create workflows & during this process if they need to give access to their google drive or google sheets or any other node that uses OAuth2, they should be able to do it directly from our platform.
It’s currently not possible for non-users of your n8n instance to complete the n8n OAuth2 process I am afraid. I’ve turned your question into a feature request so you and other users can vote on having this implemented in the future.
I am getting your point that n8n should do authenticate on instance.
If I get Oauth token from my system and then somehow can I connect it with n8n through apis?
No, I am afraid it’d only be possible to create the credentials dataset itself through n8n’s REST API, but not update them with a valid OAuth2 token after a n8n-user has completed the authentication outside of n8n.
You could try to use the CLI for this, which allows exporting and importing decrypted credentials, but this would be quite a bit of trial and error. To get started you probably want to export valid OAuth2 credentials, take a closer look at the structure and then try importing similar credentials: CLI commands - n8n Documentation