我发现scribe不会在访问令牌中提取refresh_token
。scribe不支持oauth 2.0中的refresh_token对吗?
要OAuth 1.0提取包含:
Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
String token = extract(response, TOKEN_REGEX);
String secret = extract(response, SECRET_REGEX);
return new Token(token, secret, response);
其中包含令牌密钥。
但是在OAuth2.0中,没有令牌密钥,而是代替refresh_token
。抄写员根本忽略它:
Preconditions.checkEmptyString(response, "Cannot extract a token from a null or empty String");
Matcher matcher = accessTokenPattern.matcher(response);
if(matcher.find())
{
return new Token(matcher.group(1), "", response);
}
else
{
throw new OAuthException("Cannot extract an acces token. Response was: " + response);
}
这会导致问题。访问令牌将来可能会过期。我必须在每个登录页面中通过保存的刷新令牌来刷新访问令牌,但是无法直接获取它。
我打算改进抄写员添加此功能(这并不难)......但是有没有人已经这样做?
您还需要通过CLIENT_ID和client_secret ......请注意,如果抄写没有做的OAuth2,我d只需使用oauth-signpost :-) – ejain 2013-04-05 20:23:16
这个路标? https://github.com/mttkay/signpost最后一次提交来自一年多前,它仍然不能用于LinkedIn api。祝你好运。 – 2013-04-06 15:44:59