1
我正嘗試使用Google OpenID登錄用戶。Apache Oltu OAuthClient.accessToken()失敗,超時
當我嘗試驗證用戶時,嘗試檢索AccessToken時總是遇到超時。
public class TestRun {
public static void main(String args[]) throws OAuthSystemException, OAuthProblemException {
OAuthClientRequest request = OAuthClientRequest
.tokenProvider(OAuthProviderType.GOOGLE)
.setGrantType(GrantType.AUTHORIZATION_CODE)
.setCode("")
.setRedirectURI(Env.REST_API_LOCATION+"/login")
.setClientId(Env.CLIENT_ID)
.setClientSecret(Env.CLIENT_SECRET)
.buildQueryMessage();
OAuthClient oac = new OAuthClient(new URLConnectionClient());
OAuthAccessTokenResponse response = oac.accessToken(request);
System.out.println(response.getAccessToken());
System.out.println(response.getExpiresIn());
}
}
我總是碰上的ConnectException(超時)時oac.accessToken(請求)被調用,沒有得到關於所發生的任何詳細信息。