I'm trying to post to a Salesforce Rest Resource from a java console app. Currently I'm exposing it as a public resource via custom portals. I'm looking for suggestions for a way to implement the authentication without passing username, password. I have checked OAuth flows but I believe all of them require a callback implementation to read the tokens. It will be helpful if you can suggest a way to authorize in an implicit manner.
If you want headless, no-interaction authentication, implement the JWT Flow.
You'll authorize with a private key and a username, no password. If you "pre-approve" specific Profiles and/or Permission Sets on the Connected App you build in Salesforce, no user interaction of any kind will be required.
The alternative would be to implement another flow, like Web Server, that provides you with a refresh token; in that situation you'd have a user interaction only once and can then act in headless mode via the refresh token.