Child pages
  • How to Request an HTRC Access Token

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can get Client ID and Client Secret by clicking the link of your client application.This information is required when developing the token request.

Requesting a OAuth2 Access Token

In order to request an access token you need to select one of the  authorization grant types in OAuth2. Since the client, in this scenario, will most probably run on a terminal or a desktop app, and will be trusted and known by the user, it will probably be more convenient for you to use Resource owner password credentials or Client credentials grant types to get a token.

...

Once you get back the access token from the WSO2 IS, you can save it in the session and use it with future requests to secured APIs.

Sending OAuth2 Token with Data API Request

To send a request to a Data API service instance that is protected by OAuth2, the request must have the OAuth2 Token in the HTTP request header "Authorization" as the following:

...

Code Block
languagejava
String accessToken = ... // obtain the access token from WSO2 IS
HttpsURLConnection httpsURLConnection = ... //instantiate the HTTPS URL Connection
httpsURLConnection.addRequestProperty("Authorization", "Bearer " + accessToken);

Maven Dependencies

To use OAuthClientRequest, OAuthClientResponse and OAuth2Client in your java projects, you need to add following maven dependencies and repositories to your pom.xml file.

...