@Test public void should_exchange_authorization_code_grant() throws IOException { String response = readResource("/heroku/sample-exchange-grant-code-response.json"); HerokuProvisionRequest.OAuthGrant grant = HerokuProvisionRequest.OAuthGrant.builder() .code("code") .type("authorization_code") .expires_at(Instant.now().toString()) .build(); givenThat(post("/oauth/token").willReturn(okJson(response))); HerokuOAuthTokenResponse tokenResponse = herokuApiWrapper.exchangeGrantCode(grant); assertThat(tokenResponse.getAccess_token(), is("2af695e0-93e3-4821-ac2e-95f68435f128")); }
@Override public HerokuOAuthTokenResponse exchangeGrantCode(HerokuProvisionRequest.OAuthGrant grant) { logger.debug("Exchanging {}", grant); MultiValueMap<String, String> form = createGetOAuthTokenForm("authorization_code", "code", grant.getCode()); return getHerokuOAuthTokenResponse(form); }
HerokuApiWrapperImpl implements HerokuApiWrapper { @Override public HerokuOAuthTokenResponse exchangeGrantCode(HerokuProvisionRequest.OAuthGrant grant) { logger.debug("Exchanging {}", grant); MultiValueMap<String, String> form = createGetOAuthTokenForm("authorization_code", "code", grant.getCode()); return getHerokuOAuthTokenResponse(form); } }
HerokuApiWrapperImpl implements HerokuApiWrapper { @Override public HerokuOAuthTokenResponse exchangeGrantCode(HerokuProvisionRequest.OAuthGrant grant) { logger.debug("Exchanging {}", grant); MultiValueMap<String, String> form = createGetOAuthTokenForm("authorization_code", "code", grant.getCode()); return getHerokuOAuthTokenResponse(form); }  }
HerokuApiWrapperImpl implements HerokuApiWrapper { @Override public HerokuOAuthTokenResponse exchangeGrantCode(HerokuProvisionRequest.OAuthGrant grant) { logger.debug("Exchanging {}", grant); MultiValueMap<String, String> form = createGetOAuthTokenForm("authorization_code", "code", grant.getCode()); return getHerokuOAuthTokenResponse(form); }  @Override HerokuOAuthTokenResponse exchangeGrantCode(HerokuProvisionRequest.OAuthGrant grant); @Override HerokuOAuthTokenResponse refreshAccessToken(String refreshToken); @Override HerokuAppDetails getAppDetails(String externalId, String accessToken); }
HerokuApiWrapperImpl implements HerokuApiWrapper { @Override public HerokuOAuthTokenResponse exchangeGrantCode(HerokuProvisionRequest.OAuthGrant grant) { logger.debug("Exchanging {}", grant); MultiValueMap<String, String> form = createGetOAuthTokenForm("authorization_code", "code", grant.getCode()); return getHerokuOAuthTokenResponse(form); }  @Override HerokuOAuthTokenResponse exchangeGrantCode(HerokuProvisionRequest.OAuthGrant grant); @Override HerokuOAuthTokenResponse refreshAccessToken(String refreshToken); @Override HerokuAppDetails getAppDetails(String externalId, String accessToken);  }