我正在尝试获取 Linkedin 公司更新到我的网站。按照流程https://developer.linkedin.com/documents/authentication并通过注册生成 api 密钥和密钥。
根据文档,我能够在步骤 a 中生成授权码。对于步骤 b 生成访问令牌,我在 java 中使用 OAuth。
request = OAuthClientRequest.tokenLocation("https://www.linkedin.com/uas/oauth2/accessToken")
.setGrantType(GrantType.AUTHORIZATION_CODE)
.setCode("****")
.setRedirectURI("https://www.example.in")
.setClientId("*******")
.setClientSecret("******").buildBodyMessage();
OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
GitHubTokenResponse oAuthResponse = oAuthClient.accessToken(request, GitHubTokenResponse.class);
String accessToken = oAuthResponse.getAccessToken();
String expiresIn = oAuthResponse.getExpiresIn();
但是出现错误
OAuthProblemException{description='Missing parameters: access_token', error='invalid_request', uri='null', state='null', scope='null'}
at org.apache.amber.oauth2.common.exception.OAuthProblemException.error(OAuthProblemException.java:57)
at org.apache.amber.oauth2.common.utils.OAuthUtils.handleOAuthProblemException(OAuthUtils.java:166)
at org.apache.amber.oauth2.common.utils.OAuthUtils.handleMissingParameters(OAuthUtils.java:184)
at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validateRequiredParameters(OAuthClientValidator.java:90)
at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validateParameters(OAuthClientValidator.java:53)
at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validate(OAuthClientValidator.java:49)
at org.apache.amber.oauth2.client.response.OAuthClientResponse.validate(OAuthClientResponse.java:64)
at org.apache.amber.oauth2.client.response.OAuthClientResponse.init(OAuthClientResponse.java:59)
at org.apache.amber.oauth2.client.response.OAuthAccessTokenResponse.init(OAuthAccessTokenResponse.java:52)
at org.apache.amber.oauth2.client.response.OAuthClientResponseFactory.createCustomResponse(OAuthClientResponseFactory.java:60)
at org.apache.amber.oauth2.client.URLConnectionClient.execute(URLConnectionClient.java:105)
请帮助解决这个问题。提前感谢您的帮助。