Making operation calls

This is an example about how you can perform api operation callsĀ in your app by using topoos Android SDK.

Get a valid Access Token object

To use several operations you will need a valid user Access Token.

  • If your app needs identifying different users, you must get a valid Access Token for each user using OAuth 2.0 method. Read Preferences Managed Method below.

Read this guide about how to do it.

topoos.AccessTokenOAuth token = new topoos.AccessTokenOAuth("YOUR_APPTOKEN_USER");

Store your Access Token object

In any case, you can use two methods for store your OAuthAccessToken object.

  • App managed method: Just instance the object (as described below in the single-user method example) and give it to the desired operation function.
topoos.AccessTokenOAuth token = new topoos.AccessTokenOAuth("YOUR_APPTOKEN_USER");
topoos.Positions.Operations.GetLastUser(token, "me");
  • Preferences managed method: Just call the save_Token method (only once time when you get the token) and pass the application context to it for saving it on preferences. If you used the OAuth method described above, the resulting OAuthAccessToken object is automatically stored with this method and you don’t need to do it. You can only store one OAuthAccessToken object in this manner.
topoos.AccessTokenOAuth token = new topoos.AccessTokenOAuth("YOUR_APPTOKEN_USER");
token.save_Token(this);

Make the operation calls

Just call the operation that you want to perform:

  • Using app managed method
topoos.AccessTokenOAuth token = new topoos.AccessTokenOAuth("YOUR_APPTOKEN_USER");
topoos.Positions.Operations.GetLastUser(token, "me");
  • Using preferences managed method
topoos.Positions.Operations.GetLastUser(this, "me");

How to manage token expiration time

You can check if the token expiration time is reached by using isValid method. Read more about token expiration time.

        if (!token.isValid())
        {
        	//Expiration time reached
        }