@Test public void exchangeCredentialsForAccess() { AccessGrant accessGrant = passwordGrant("accessToken.json"); assertEquals("8d0a88a5c4f1ae4937ad864cafa8e857", accessGrant.getAccessToken()); assertEquals("6b0411401bf8751e34f57feb29fb8e32", accessGrant.getRefreshToken()); long approximateExpirationTime = System.currentTimeMillis() + 40735000; long actualExpirationTime = (long) accessGrant.getExpireTime(); assertTrue(approximateExpirationTime - actualExpirationTime < 1000); assertEquals("read", accessGrant.getScope()); }
public AccessGrant exchangeCredentialsForAccess(String username, String password, MultiValueMap<String, String> additionalParameters) { MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(); if (useParametersForClientAuthentication) { params.set("client_id", clientId); params.set("client_secret", clientSecret); } params.set("username", username); params.set("password", password); params.set("grant_type", "password"); if (additionalParameters != null) { params.putAll(additionalParameters); } return postForAccessGrant(accessTokenUrl, params); }
OAuth2Template implements OAuth2Operations { public AccessGrant exchangeCredentialsForAccess(String username, String password, MultiValueMap<String, String> additionalParameters) { MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(); if (useParametersForClientAuthentication) { params.set("client_id", clientId); params.set("client_secret", clientSecret); } params.set("username", username); params.set("password", password); params.set("grant_type", "password"); if (additionalParameters != null) { params.putAll(additionalParameters); } return postForAccessGrant(accessTokenUrl, params); } }
OAuth2Template implements OAuth2Operations { public AccessGrant exchangeCredentialsForAccess(String username, String password, MultiValueMap<String, String> additionalParameters) { MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(); if (useParametersForClientAuthentication) { params.set("client_id", clientId); params.set("client_secret", clientSecret); } params.set("username", username); params.set("password", password); params.set("grant_type", "password"); if (additionalParameters != null) { params.putAll(additionalParameters); } return postForAccessGrant(accessTokenUrl, params); } OAuth2Template(String clientId, String clientSecret, String authorizeUrl, String accessTokenUrl);  OAuth2Template(String clientId, String clientSecret, String authorizeUrl, String authenticateUrl, String accessTokenUrl); }
OAuth2Template implements OAuth2Operations { public AccessGrant exchangeCredentialsForAccess(String username, String password, MultiValueMap<String, String> additionalParameters) { MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(); if (useParametersForClientAuthentication) { params.set("client_id", clientId); params.set("client_secret", clientSecret); } params.set("username", username); params.set("password", password); params.set("grant_type", "password"); if (additionalParameters != null) { params.putAll(additionalParameters); } return postForAccessGrant(accessTokenUrl, params); } OAuth2Template(String clientId, String clientSecret, String authorizeUrl, String accessTokenUrl);  OAuth2Template(String clientId, String clientSecret, String authorizeUrl, String authenticateUrl, String accessTokenUrl); void setUseParametersForClientAuthentication(boolean useParametersForClientAuthentication); void setRequestFactory(ClientHttpRequestFactory requestFactory); String buildAuthorizeUrl(OAuth2Parameters parameters); String buildAuthorizeUrl(GrantType grantType, OAuth2Parameters parameters); String buildAuthenticateUrl(OAuth2Parameters parameters); String buildAuthenticateUrl(GrantType grantType, OAuth2Parameters parameters); AccessGrant exchangeForAccess(String authorizationCode, String redirectUri, MultiValueMap<String, String> additionalParameters); AccessGrant exchangeCredentialsForAccess(String username, String password, MultiValueMap<String, String> additionalParameters); @Deprecated AccessGrant refreshAccess(String refreshToken, String scope, MultiValueMap<String, String> additionalParameters); AccessGrant refreshAccess(String refreshToken, MultiValueMap<String, String> additionalParameters); AccessGrant authenticateClient(); AccessGrant authenticateClient(String scope); }
OAuth2Template implements OAuth2Operations { public AccessGrant exchangeCredentialsForAccess(String username, String password, MultiValueMap<String, String> additionalParameters) { MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(); if (useParametersForClientAuthentication) { params.set("client_id", clientId); params.set("client_secret", clientSecret); } params.set("username", username); params.set("password", password); params.set("grant_type", "password"); if (additionalParameters != null) { params.putAll(additionalParameters); } return postForAccessGrant(accessTokenUrl, params); } OAuth2Template(String clientId, String clientSecret, String authorizeUrl, String accessTokenUrl);  OAuth2Template(String clientId, String clientSecret, String authorizeUrl, String authenticateUrl, String accessTokenUrl); void setUseParametersForClientAuthentication(boolean useParametersForClientAuthentication); void setRequestFactory(ClientHttpRequestFactory requestFactory); String buildAuthorizeUrl(OAuth2Parameters parameters); String buildAuthorizeUrl(GrantType grantType, OAuth2Parameters parameters); String buildAuthenticateUrl(OAuth2Parameters parameters); String buildAuthenticateUrl(GrantType grantType, OAuth2Parameters parameters); AccessGrant exchangeForAccess(String authorizationCode, String redirectUri, MultiValueMap<String, String> additionalParameters); AccessGrant exchangeCredentialsForAccess(String username, String password, MultiValueMap<String, String> additionalParameters); @Deprecated AccessGrant refreshAccess(String refreshToken, String scope, MultiValueMap<String, String> additionalParameters); AccessGrant refreshAccess(String refreshToken, MultiValueMap<String, String> additionalParameters); AccessGrant authenticateClient(); AccessGrant authenticateClient(String scope);  }