Created
February 3, 2017 06:50
-
-
Save pyeongho/4d5b2c096baf1eefb76c39bf2f418cdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AppClient { | |
public static Retrofit mRetrofit; | |
public static Retrofit retrofit() { | |
if (mRetrofit == null) { | |
OkHttpClient.Builder builder = new OkHttpClient.Builder(); | |
if (BuildConfig.DEBUG) { | |
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); | |
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); | |
builder.addInterceptor(loggingInterceptor); | |
} | |
final String clientId = "NAVER client id ";//애플리케이션 클라이언트 아이디값"; | |
final String clientSecret = "NAVER secret id";//애플리케이션 클라이언트 시크릿값"; | |
builder.addInterceptor(new Interceptor() { | |
@Override | |
public Response intercept(Chain chain) throws IOException { | |
Request request = chain.request().newBuilder() | |
.addHeader("X-Naver-Client-Id", clientId) | |
.addHeader("X-Naver-Client-Secret", clientSecret) | |
.build(); | |
return chain.proceed(request); | |
} | |
}); | |
OkHttpClient okHttpClient = builder.build(); | |
mRetrofit = new Retrofit.Builder() | |
.baseUrl(ApiStores.API_SERVER_URL) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.client(okHttpClient) | |
.build(); | |
} | |
return mRetrofit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment