本文整理汇总了Java中io.swagger.client.auth.ApiKeyAuth.setApiKey方法的典型用法代码示例。如果您正苦于以下问题:Java ApiKeyAuth.setApiKey方法的具体用法?Java ApiKeyAuth.setApiKey怎么用?Java ApiKeyAuth.setApiKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.swagger.client.auth.ApiKeyAuth
的用法示例。
在下文中一共展示了ApiKeyAuth.setApiKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAuth
import io.swagger.client.auth.ApiKeyAuth; //导入方法依赖的package包/类
private static boolean setAuth(String method) {
if (method != null && !method.isEmpty()) {
ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication(method);
auth.setApiKey(dataProvider.getCurrentUserUid());
return true;
}
return false;
}
示例2: setApiKey
import io.swagger.client.auth.ApiKeyAuth; //导入方法依赖的package包/类
/**
* Helper method to configure the first api key found
* @param apiKey API key
*/
private void setApiKey(String apiKey) {
for(Interceptor apiAuthorization : apiAuthorizations.values()) {
if (apiAuthorization instanceof ApiKeyAuth) {
ApiKeyAuth keyAuth = (ApiKeyAuth) apiAuthorization;
keyAuth.setApiKey(apiKey);
return;
}
}
}
示例3: createClient
import io.swagger.client.auth.ApiKeyAuth; //导入方法依赖的package包/类
public static LuckyCaloriesApi createClient(String access_token){
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
.create();
//String baseUrl = "http://localhost:4003/api/v1";
String baseUrl = "http://10.0.2.2:4003/api/v1"; //from emulator to host computer (localhost)
if(!baseUrl.endsWith("/"))
baseUrl = baseUrl + "/";
OkHttpClient.Builder okHttpBuilder = new OkHttpClient.Builder();
if(access_token != null){
ApiKeyAuth authInterceptor = new ApiKeyAuth("header", "access_token");
authInterceptor.setApiKey(access_token);
okHttpBuilder.addInterceptor(authInterceptor);
}
Retrofit retrofit = new Retrofit
.Builder()
.baseUrl(baseUrl)
.client(okHttpBuilder.build())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonCustomConverterFactory.create(gson))
.build();
return retrofit.create(LuckyCaloriesApi.class);
}
示例4: setApiKey
import io.swagger.client.auth.ApiKeyAuth; //导入方法依赖的package包/类
/**
* Helper method to configure the first api key found
* @param apiKey
*/
private void setApiKey(String apiKey) {
for(Interceptor apiAuthorization : apiAuthorizations.values()) {
if (apiAuthorization instanceof ApiKeyAuth) {
ApiKeyAuth keyAuth = (ApiKeyAuth) apiAuthorization;
keyAuth.setApiKey(apiKey);
return;
}
}
}