Oauth 2.0 LinkedIn Oauth2使用Java引发异常

Oauth 2.0 LinkedIn Oauth2使用Java引发异常,oauth-2.0,linkedin,Oauth 2.0,Linkedin,这是教程中的代码,我只是在尝试,其他的都没有运行 public class Launch { private static final String url = "http://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name,email-address,picture-url)"; private static final String url2 = "http://api.linke

这是教程中的代码,我只是在尝试,其他的都没有运行

 public class Launch {

private static final String url =
    "http://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name,email-address,picture-url)";
private static final String url2 =
        "http://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name)";

public Launch() {
    OAuthService service = new ServiceBuilder()
            .provider(LinkedInApi.class)
            .apiKey("xxxx")
            .apiSecret("xxxx")
            .build();
    Token requestToken = service.getRequestToken();

    String authUrl = service.getAuthorizationUrl(requestToken);
    Verifier v = new Verifier("verifier you got from the user");
    Token accessToken = service.getAccessToken(requestToken, v); // the requestToken you had from step 2
    OAuthRequest request = new OAuthRequest(Verb.GET, url2);
    service.signRequest(accessToken, request); // the access token from step 4
    Response response = request.send();
    System.out.println(response.getBody());
}
在我的控制器中我有:

@View
public Response.Content index(){
Launch launch = new Launch();
return index.ok();}
当我尝试启动它时,它会给我以下错误:

org.scribe.exceptions.oautheexception:响应正文不正确。无法从此中提取令牌和机密:“oauth\u problem=permission\u unknown”


找到解决方案:将代码更改为添加
Scanner in=new Scanner(System.in)
ServiceBuilder
声明之后,在
Verifier-Verifier=new-Verifier(in.nextLine())中使用它

另外,手动输入在终端中找到的url,这是
System.out.println(service.getAuthorizationUrl(requestToken))的结果

这是一个临时url,但到目前为止,这是唯一有效的方法