0

Following this tutorial I manage to get token. How now I use this to token to get tweets from user, for example? Where should I place this token variable and make API call with retrofit?

twitterApi.postCredentials("client_credentials").enqueue(new Callback<OAuthToken>() {
@Override
public void onResponse(Call<OAuthToken> call, Response<OAuthToken> response) {
    token = response.body();  // <---- my token
}

@Override
public void onFailure(Call<OAuthToken> call, Throwable t) {
    // fail
}});
Personal Jesus
  • 133
  • 2
  • 10

1 Answers1

1

You could add it in all requests using interceptors, as descibed here How to use interceptor to add Headers in Retrofit 2.0

Ignacio Tomas Crespo
  • 3,401
  • 1
  • 20
  • 13