How to get oauth_verifier without manual intervention

I'm trying to get an access token for LinkedIn. Here is part of the code,

OAuthService service = new ServiceBuilder().provider(LinkedInApi.class).apiKey("My_Api_Key").apiSecret("My_secret_key").build(); System.out.println("LinkedIn Service created"); Token token = service.getRequestToken(); System.out.println("Got Request token"); System.out.println(service.getAuthorizationUrl(token)); //https://api.linkedin.com/uas/oauth/authorize?oauth_token=some_value Verifier verifier = new Verifier("verifier_you_got_previously"); 

I can get the request token and authorization URL https://api.linkedin.com/uas/oauth/authorize?oauth_token=some_value To get the Verifier object, I need to pass the value of the verifier to the constructor. How to get this value? This is an oob request, so the service does not require a callback. What should I do with Url authorization to get oauth_verifier ?

+4
source share
2 answers

Your server will not receive a verifier. You need to redirect the user to authorizationUrl , and then ask them to provide it to you somehow.

This is how OAuth works; you cannot fool the system.

+5
source

Use the HTTP client to request a POST for the authorization URL.

0
source

Source: https://habr.com/ru/post/1386260/


All Articles