I'm writing a service with no UI that must connect to a web API using OAuth2. I have everything - Client ID, Client Secret, Auth URL, Callback URL, Username, and Password.
I want to know the easiest way to exchange the username, password, etc. for an OAuth2 token so I may authenticate with the web API.
I've been looking at Apache Oltu, and the canonical workflow seems to be:
- Use
OAuthClientRequestto build the request URI - Redirect to the URI so the user can grant access
- Retrieve the corresponding code via
OAuthAccessTokenResponseand use it to authenticate
Again - I cannot have the app prompt the user; everything must happen programmatically.
I think I'm looking for something like DotNetOpenAuth's ExchangeUserCredentialForToken() method, but for Java.
I'm leaning towards using Apache Oltu, but I'm open to any framework / solution. Thanks!