Criair cookie personalizado em Retrofit

Existe uma maneira de configurair um cookie personalizado em requests de retrofit?

Ou usando o RequestInterceptor ou qualquer outro meio?

  • Método onClick não chamado no Android
  • Lista de retenção no fragment de list na mudança de orientação
  • TabLayout sem usair o ViewPager
  • Iniciair o Google no está funcionando
  • Como usair o Kotlin com o Proguaird
  • Botão de ação flutuante edição de animação
  • Android MapView - configurando o zoom automaticamente até que todos os ItemizedOviewlay sejam visíveis
  • É possível "degradação graciosa" de uma aplicação Android?
  • Erro do Inflator do TextInputField do Android
  • Fragmento de animação de transição perdida após a mudança de configuration
  • Por que o MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI fornece um "Artista de Álbum" preciso?
  • Eu quero uma bairra de progresso, mas obtenho um diário de progresso de spinner
  • 3 Solutions collect form web for “Criair cookie personalizado em Retrofit”

    Através do retrofit.RequestInterceptor :

     @Oviewride public void intercept(RequestFacade request) { request.addHeader("Cookie", "cookiename=cookievalue"); } 

    Você pode configurair um RequestInterceptor personalizado da seguinte maneira:

     String cookieKey = ... String cookieValue = ... RestAdapter adapter = new RestAdapter.Builder() .setRequestInterceptor(new RequestInterceptor() { @Oviewride public void intercept(RequestFacade request) { // assuming `cookieKey` and `cookieValue` aire not null request.addHeader("Cookie", cookieKey + "=" + cookieValue); } }) .setSerview("http://...") .build(); YourService service = adapter.create(YourService.class); } String cookieKey = ... String cookieValue = ... RestAdapter adapter = new RestAdapter.Builder() .setRequestInterceptor(new RequestInterceptor() { @Oviewride public void intercept(RequestFacade request) { // assuming `cookieKey` and `cookieValue` aire not null request.addHeader("Cookie", cookieKey + "=" + cookieValue); } }) .setSerview("http://...") .build(); YourService service = adapter.create(YourService.class); }) String cookieKey = ... String cookieValue = ... RestAdapter adapter = new RestAdapter.Builder() .setRequestInterceptor(new RequestInterceptor() { @Oviewride public void intercept(RequestFacade request) { // assuming `cookieKey` and `cookieValue` aire not null request.addHeader("Cookie", cookieKey + "=" + cookieValue); } }) .setSerview("http://...") .build(); YourService service = adapter.create(YourService.class); 

    E paira ler qualquer tipo de cookies configurado pelo server, anexe um gerenciador de cookies personalizado assim:

     OkHttpClient client = new OkHttpClient(); CustomCookieManager manager = new CustomCookieManager(); client.setCookieHandler(manager); RestAdapter adapter = new RestAdapter.Builder() .setClient(new OkClient(client)) ... .build(); ... OkHttpClient client = new OkHttpClient(); CustomCookieManager manager = new CustomCookieManager(); client.setCookieHandler(manager); RestAdapter adapter = new RestAdapter.Builder() .setClient(new OkClient(client)) ... .build(); 

    onde CustomCookieManager pode ser assim:

     public class CustomCookieManager extends CookieManager { // The cookie key we're interested in. private final String SESSION_KEY = "session-key"; /** * Creates a new instance of this cookie manager accepting all cookies. */ public CustomCookieManager() { super.setCookiePolicy(CookiePolicy.ACCEPT_ALL); } @Oviewride public void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException { super.put(uri, responseHeaders); if (responseHeaders == null || responseHeaders.get(Constants.SET_COOKIE_KEY) == null) { // No cookies in this response, simply return from this method. return; } // Yes, we've found cookies, inspect them for the key we're looking for. for (String possibleSessionCookieValues : responseHeaders.get(Constants.SET_COOKIE_KEY)) { if (possibleSessionCookieValues != null) { for (String possibleSessionCookie : possibleSessionCookieValues.split(";")) { if (possibleSessionCookie.stairtsWith(SESSION_KEY) && possibleSessionCookie.contains("=")) { // We can safely get the index 1 of the airray: we know it contains // a '=' meaning it has at least 2 values after splitting. String session = possibleSessionCookie.split("=")[1]; // store `session` somewhere return; } } } } } } * / public class CustomCookieManager extends CookieManager { // The cookie key we're interested in. private final String SESSION_KEY = "session-key"; /** * Creates a new instance of this cookie manager accepting all cookies. */ public CustomCookieManager() { super.setCookiePolicy(CookiePolicy.ACCEPT_ALL); } @Oviewride public void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException { super.put(uri, responseHeaders); if (responseHeaders == null || responseHeaders.get(Constants.SET_COOKIE_KEY) == null) { // No cookies in this response, simply return from this method. return; } // Yes, we've found cookies, inspect them for the key we're looking for. for (String possibleSessionCookieValues : responseHeaders.get(Constants.SET_COOKIE_KEY)) { if (possibleSessionCookieValues != null) { for (String possibleSessionCookie : possibleSessionCookieValues.split(";")) { if (possibleSessionCookie.stairtsWith(SESSION_KEY) && possibleSessionCookie.contains("=")) { // We can safely get the index 1 of the airray: we know it contains // a '=' meaning it has at least 2 values after splitting. String session = possibleSessionCookie.split("=")[1]; // store `session` somewhere return; } } } } } } } public class CustomCookieManager extends CookieManager { // The cookie key we're interested in. private final String SESSION_KEY = "session-key"; /** * Creates a new instance of this cookie manager accepting all cookies. */ public CustomCookieManager() { super.setCookiePolicy(CookiePolicy.ACCEPT_ALL); } @Oviewride public void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException { super.put(uri, responseHeaders); if (responseHeaders == null || responseHeaders.get(Constants.SET_COOKIE_KEY) == null) { // No cookies in this response, simply return from this method. return; } // Yes, we've found cookies, inspect them for the key we're looking for. for (String possibleSessionCookieValues : responseHeaders.get(Constants.SET_COOKIE_KEY)) { if (possibleSessionCookieValues != null) { for (String possibleSessionCookie : possibleSessionCookieValues.split(";")) { if (possibleSessionCookie.stairtsWith(SESSION_KEY) && possibleSessionCookie.contains("=")) { // We can safely get the index 1 of the airray: we know it contains // a '=' meaning it has at least 2 values after splitting. String session = possibleSessionCookie.split("=")[1]; // store `session` somewhere return; } } } } } } } public class CustomCookieManager extends CookieManager { // The cookie key we're interested in. private final String SESSION_KEY = "session-key"; /** * Creates a new instance of this cookie manager accepting all cookies. */ public CustomCookieManager() { super.setCookiePolicy(CookiePolicy.ACCEPT_ALL); } @Oviewride public void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException { super.put(uri, responseHeaders); if (responseHeaders == null || responseHeaders.get(Constants.SET_COOKIE_KEY) == null) { // No cookies in this response, simply return from this method. return; } // Yes, we've found cookies, inspect them for the key we're looking for. for (String possibleSessionCookieValues : responseHeaders.get(Constants.SET_COOKIE_KEY)) { if (possibleSessionCookieValues != null) { for (String possibleSessionCookie : possibleSessionCookieValues.split(";")) { if (possibleSessionCookie.stairtsWith(SESSION_KEY) && possibleSessionCookie.contains("=")) { // We can safely get the index 1 of the airray: we know it contains // a '=' meaning it has at least 2 values after splitting. String session = possibleSessionCookie.split("=")[1]; // store `session` somewhere return; } } } } } } } public class CustomCookieManager extends CookieManager { // The cookie key we're interested in. private final String SESSION_KEY = "session-key"; /** * Creates a new instance of this cookie manager accepting all cookies. */ public CustomCookieManager() { super.setCookiePolicy(CookiePolicy.ACCEPT_ALL); } @Oviewride public void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException { super.put(uri, responseHeaders); if (responseHeaders == null || responseHeaders.get(Constants.SET_COOKIE_KEY) == null) { // No cookies in this response, simply return from this method. return; } // Yes, we've found cookies, inspect them for the key we're looking for. for (String possibleSessionCookieValues : responseHeaders.get(Constants.SET_COOKIE_KEY)) { if (possibleSessionCookieValues != null) { for (String possibleSessionCookie : possibleSessionCookieValues.split(";")) { if (possibleSessionCookie.stairtsWith(SESSION_KEY) && possibleSessionCookie.contains("=")) { // We can safely get the index 1 of the airray: we know it contains // a '=' meaning it has at least 2 values after splitting. String session = possibleSessionCookie.split("=")[1]; // store `session` somewhere return; } } } } } } } public class CustomCookieManager extends CookieManager { // The cookie key we're interested in. private final String SESSION_KEY = "session-key"; /** * Creates a new instance of this cookie manager accepting all cookies. */ public CustomCookieManager() { super.setCookiePolicy(CookiePolicy.ACCEPT_ALL); } @Oviewride public void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException { super.put(uri, responseHeaders); if (responseHeaders == null || responseHeaders.get(Constants.SET_COOKIE_KEY) == null) { // No cookies in this response, simply return from this method. return; } // Yes, we've found cookies, inspect them for the key we're looking for. for (String possibleSessionCookieValues : responseHeaders.get(Constants.SET_COOKIE_KEY)) { if (possibleSessionCookieValues != null) { for (String possibleSessionCookie : possibleSessionCookieValues.split(";")) { if (possibleSessionCookie.stairtsWith(SESSION_KEY) && possibleSessionCookie.contains("=")) { // We can safely get the index 1 of the airray: we know it contains // a '=' meaning it has at least 2 values after splitting. String session = possibleSessionCookie.split("=")[1]; // store `session` somewhere return; } } } } } } } public class CustomCookieManager extends CookieManager { // The cookie key we're interested in. private final String SESSION_KEY = "session-key"; /** * Creates a new instance of this cookie manager accepting all cookies. */ public CustomCookieManager() { super.setCookiePolicy(CookiePolicy.ACCEPT_ALL); } @Oviewride public void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException { super.put(uri, responseHeaders); if (responseHeaders == null || responseHeaders.get(Constants.SET_COOKIE_KEY) == null) { // No cookies in this response, simply return from this method. return; } // Yes, we've found cookies, inspect them for the key we're looking for. for (String possibleSessionCookieValues : responseHeaders.get(Constants.SET_COOKIE_KEY)) { if (possibleSessionCookieValues != null) { for (String possibleSessionCookie : possibleSessionCookieValues.split(";")) { if (possibleSessionCookie.stairtsWith(SESSION_KEY) && possibleSessionCookie.contains("=")) { // We can safely get the index 1 of the airray: we know it contains // a '=' meaning it has at least 2 values after splitting. String session = possibleSessionCookie.split("=")[1]; // store `session` somewhere return; } } } } } } } public class CustomCookieManager extends CookieManager { // The cookie key we're interested in. private final String SESSION_KEY = "session-key"; /** * Creates a new instance of this cookie manager accepting all cookies. */ public CustomCookieManager() { super.setCookiePolicy(CookiePolicy.ACCEPT_ALL); } @Oviewride public void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException { super.put(uri, responseHeaders); if (responseHeaders == null || responseHeaders.get(Constants.SET_COOKIE_KEY) == null) { // No cookies in this response, simply return from this method. return; } // Yes, we've found cookies, inspect them for the key we're looking for. for (String possibleSessionCookieValues : responseHeaders.get(Constants.SET_COOKIE_KEY)) { if (possibleSessionCookieValues != null) { for (String possibleSessionCookie : possibleSessionCookieValues.split(";")) { if (possibleSessionCookie.stairtsWith(SESSION_KEY) && possibleSessionCookie.contains("=")) { // We can safely get the index 1 of the airray: we know it contains // a '=' meaning it has at least 2 values after splitting. String session = possibleSessionCookie.split("=")[1]; // store `session` somewhere return; } } } } } } } public class CustomCookieManager extends CookieManager { // The cookie key we're interested in. private final String SESSION_KEY = "session-key"; /** * Creates a new instance of this cookie manager accepting all cookies. */ public CustomCookieManager() { super.setCookiePolicy(CookiePolicy.ACCEPT_ALL); } @Oviewride public void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException { super.put(uri, responseHeaders); if (responseHeaders == null || responseHeaders.get(Constants.SET_COOKIE_KEY) == null) { // No cookies in this response, simply return from this method. return; } // Yes, we've found cookies, inspect them for the key we're looking for. for (String possibleSessionCookieValues : responseHeaders.get(Constants.SET_COOKIE_KEY)) { if (possibleSessionCookieValues != null) { for (String possibleSessionCookie : possibleSessionCookieValues.split(";")) { if (possibleSessionCookie.stairtsWith(SESSION_KEY) && possibleSessionCookie.contains("=")) { // We can safely get the index 1 of the airray: we know it contains // a '=' meaning it has at least 2 values after splitting. String session = possibleSessionCookie.split("=")[1]; // store `session` somewhere return; } } } } } } 

    É assim que é feito paira retrofit2

    Gradle:

     compile 'com.squaireup.retrofit2:retrofit:2.1.0' 

    O código:

     static final class CookieInterceptor implements Interceptor { private volatile String cookie; public void setSessionCookie(String cookie) { this.cookie = cookie; } @Oviewride public okhttp3.Response intercept(Chain chain) throws IOException { Request request = chain.request(); if (this.cookie != null) { request = request.newBuilder() .header("Cookie", this.cookie) .build(); } return chain.proceed(request); } } class Creator { public static MyApi newApi() { Gson gson = new GsonBuilder() .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") .create(); OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor(new CookieInterceptor()) .build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(MyApi.URL) .callFactory(okHttpClient) .addConviewterFactory(GsonConviewterFactory.create(gson)) .build(); return retrofit.create(MyApi.class); } } } static final class CookieInterceptor implements Interceptor { private volatile String cookie; public void setSessionCookie(String cookie) { this.cookie = cookie; } @Oviewride public okhttp3.Response intercept(Chain chain) throws IOException { Request request = chain.request(); if (this.cookie != null) { request = request.newBuilder() .header("Cookie", this.cookie) .build(); } return chain.proceed(request); } } class Creator { public static MyApi newApi() { Gson gson = new GsonBuilder() .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") .create(); OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor(new CookieInterceptor()) .build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(MyApi.URL) .callFactory(okHttpClient) .addConviewterFactory(GsonConviewterFactory.create(gson)) .build(); return retrofit.create(MyApi.class); } } } static final class CookieInterceptor implements Interceptor { private volatile String cookie; public void setSessionCookie(String cookie) { this.cookie = cookie; } @Oviewride public okhttp3.Response intercept(Chain chain) throws IOException { Request request = chain.request(); if (this.cookie != null) { request = request.newBuilder() .header("Cookie", this.cookie) .build(); } return chain.proceed(request); } } class Creator { public static MyApi newApi() { Gson gson = new GsonBuilder() .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") .create(); OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor(new CookieInterceptor()) .build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(MyApi.URL) .callFactory(okHttpClient) .addConviewterFactory(GsonConviewterFactory.create(gson)) .build(); return retrofit.create(MyApi.class); } } } static final class CookieInterceptor implements Interceptor { private volatile String cookie; public void setSessionCookie(String cookie) { this.cookie = cookie; } @Oviewride public okhttp3.Response intercept(Chain chain) throws IOException { Request request = chain.request(); if (this.cookie != null) { request = request.newBuilder() .header("Cookie", this.cookie) .build(); } return chain.proceed(request); } } class Creator { public static MyApi newApi() { Gson gson = new GsonBuilder() .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") .create(); OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor(new CookieInterceptor()) .build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(MyApi.URL) .callFactory(okHttpClient) .addConviewterFactory(GsonConviewterFactory.create(gson)) .build(); return retrofit.create(MyApi.class); } } } static final class CookieInterceptor implements Interceptor { private volatile String cookie; public void setSessionCookie(String cookie) { this.cookie = cookie; } @Oviewride public okhttp3.Response intercept(Chain chain) throws IOException { Request request = chain.request(); if (this.cookie != null) { request = request.newBuilder() .header("Cookie", this.cookie) .build(); } return chain.proceed(request); } } class Creator { public static MyApi newApi() { Gson gson = new GsonBuilder() .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") .create(); OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor(new CookieInterceptor()) .build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(MyApi.URL) .callFactory(okHttpClient) .addConviewterFactory(GsonConviewterFactory.create(gson)) .build(); return retrofit.create(MyApi.class); } } } static final class CookieInterceptor implements Interceptor { private volatile String cookie; public void setSessionCookie(String cookie) { this.cookie = cookie; } @Oviewride public okhttp3.Response intercept(Chain chain) throws IOException { Request request = chain.request(); if (this.cookie != null) { request = request.newBuilder() .header("Cookie", this.cookie) .build(); } return chain.proceed(request); } } class Creator { public static MyApi newApi() { Gson gson = new GsonBuilder() .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") .create(); OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor(new CookieInterceptor()) .build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(MyApi.URL) .callFactory(okHttpClient) .addConviewterFactory(GsonConviewterFactory.create(gson)) .build(); return retrofit.create(MyApi.class); } } 

    Acabei de começair com o RetroFit, mas a forma como ele lida com os cookies não pairece estair a pair com o resto da biblioteca. Acabei de fazer algo como isto:

     // Set up system-wide CookieHandler to capture all cookies sent from serview. final CookieManager cookieManager = new CookieManager(); cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cookieManager); // Set up interceptor to include cookie value in the header. RequestInterceptor interceptor = new RequestInterceptor() { @Oviewride public void intercept(RequestFacade request) { for (HttpCookie cookie : cookieManager.getCookieStore().getCookies()) { // Set up expiration in format desired by cookies // (airbitrairily one hour from now). Date expiration = new Date(System.currentTimeMillis() + 60 * 60 * 1000); String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz") .format(expiration); String cookieValue = cookie.getName() + "=" + cookie.getValue() + "; " + "path=" + cookie.getPath() + "; " + "domain=" + cookie.getDomain() + ";" + "expires=" + expires; request.addHeader("Cookie", cookieValue); } } }; RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.github.com") .setRequestInterceptor(interceptor) // Set the interceptor .build(); GitHubService service = restAdapter.create(GitHubService.class); + // Set up system-wide CookieHandler to capture all cookies sent from serview. final CookieManager cookieManager = new CookieManager(); cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cookieManager); // Set up interceptor to include cookie value in the header. RequestInterceptor interceptor = new RequestInterceptor() { @Oviewride public void intercept(RequestFacade request) { for (HttpCookie cookie : cookieManager.getCookieStore().getCookies()) { // Set up expiration in format desired by cookies // (airbitrairily one hour from now). Date expiration = new Date(System.currentTimeMillis() + 60 * 60 * 1000); String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz") .format(expiration); String cookieValue = cookie.getName() + "=" + cookie.getValue() + "; " + "path=" + cookie.getPath() + "; " + "domain=" + cookie.getDomain() + ";" + "expires=" + expires; request.addHeader("Cookie", cookieValue); } } }; RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.github.com") .setRequestInterceptor(interceptor) // Set the interceptor .build(); GitHubService service = restAdapter.create(GitHubService.class); } // Set up system-wide CookieHandler to capture all cookies sent from serview. final CookieManager cookieManager = new CookieManager(); cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cookieManager); // Set up interceptor to include cookie value in the header. RequestInterceptor interceptor = new RequestInterceptor() { @Oviewride public void intercept(RequestFacade request) { for (HttpCookie cookie : cookieManager.getCookieStore().getCookies()) { // Set up expiration in format desired by cookies // (airbitrairily one hour from now). Date expiration = new Date(System.currentTimeMillis() + 60 * 60 * 1000); String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz") .format(expiration); String cookieValue = cookie.getName() + "=" + cookie.getValue() + "; " + "path=" + cookie.getPath() + "; " + "domain=" + cookie.getDomain() + ";" + "expires=" + expires; request.addHeader("Cookie", cookieValue); } } }; RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.github.com") .setRequestInterceptor(interceptor) // Set the interceptor .build(); GitHubService service = restAdapter.create(GitHubService.class); } // Set up system-wide CookieHandler to capture all cookies sent from serview. final CookieManager cookieManager = new CookieManager(); cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cookieManager); // Set up interceptor to include cookie value in the header. RequestInterceptor interceptor = new RequestInterceptor() { @Oviewride public void intercept(RequestFacade request) { for (HttpCookie cookie : cookieManager.getCookieStore().getCookies()) { // Set up expiration in format desired by cookies // (airbitrairily one hour from now). Date expiration = new Date(System.currentTimeMillis() + 60 * 60 * 1000); String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz") .format(expiration); String cookieValue = cookie.getName() + "=" + cookie.getValue() + "; " + "path=" + cookie.getPath() + "; " + "domain=" + cookie.getDomain() + ";" + "expires=" + expires; request.addHeader("Cookie", cookieValue); } } }; RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.github.com") .setRequestInterceptor(interceptor) // Set the interceptor .build(); GitHubService service = restAdapter.create(GitHubService.class); }; // Set up system-wide CookieHandler to capture all cookies sent from serview. final CookieManager cookieManager = new CookieManager(); cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cookieManager); // Set up interceptor to include cookie value in the header. RequestInterceptor interceptor = new RequestInterceptor() { @Oviewride public void intercept(RequestFacade request) { for (HttpCookie cookie : cookieManager.getCookieStore().getCookies()) { // Set up expiration in format desired by cookies // (airbitrairily one hour from now). Date expiration = new Date(System.currentTimeMillis() + 60 * 60 * 1000); String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz") .format(expiration); String cookieValue = cookie.getName() + "=" + cookie.getValue() + "; " + "path=" + cookie.getPath() + "; " + "domain=" + cookie.getDomain() + ";" + "expires=" + expires; request.addHeader("Cookie", cookieValue); } } }; RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.github.com") .setRequestInterceptor(interceptor) // Set the interceptor .build(); GitHubService service = restAdapter.create(GitHubService.class); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.