本文整理汇总了Java中io.swagger.client.auth.ApiKeyAuth类的典型用法代码示例。如果您正苦于以下问题:Java ApiKeyAuth类的具体用法?Java ApiKeyAuth怎么用?Java ApiKeyAuth使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApiKeyAuth类属于io.swagger.client.auth包,在下文中一共展示了ApiKeyAuth类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setApiKey
import io.swagger.client.auth.ApiKeyAuth; //导入依赖的package包/类
/**
* Helper method to set API key value for the first API key authentication.
*/
public void setApiKey(String apiKey) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKey(apiKey);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
}
示例2: setApiKeyPrefix
import io.swagger.client.auth.ApiKeyAuth; //导入依赖的package包/类
/**
* Helper method to set API key prefix for the first API key authentication.
*/
public void setApiKeyPrefix(String apiKeyPrefix) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
}
示例3: 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;
}
示例4: 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;
}
}
}
示例5: setApiKey
import io.swagger.client.auth.ApiKeyAuth; //导入依赖的package包/类
/**
* Helper method to set API key value for the first API key authentication.
*
* @param apiKey API key
*/
public void setApiKey(String apiKey) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKey(apiKey);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
}
示例6: setApiKeyPrefix
import io.swagger.client.auth.ApiKeyAuth; //导入依赖的package包/类
/**
* Helper method to set API key prefix for the first API key authentication.
*
* @param apiKeyPrefix API key prefix
*/
public void setApiKeyPrefix(String apiKeyPrefix) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
}
示例7: initializeInstance
import io.swagger.client.auth.ApiKeyAuth; //导入依赖的package包/类
public static void initializeInstance(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) {
INSTANCE = new ApiInvoker(cache, network, threadPoolSize, delivery, connectionTimeout);
setUserAgent("Swagger-Codegen/1.0.0/android");
// Setup authentications (key: authentication name, value: authentication).
INSTANCE.authentications = new HashMap<String, Authentication>();
INSTANCE.authentications.put("Bearer", new ApiKeyAuth("header", "Authorization"));
// Prevent the authentications from being modified.
INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications);
}
示例8: setApiKey
import io.swagger.client.auth.ApiKeyAuth; //导入依赖的package包/类
/**
* Helper method to set API key value for the first API key authentication.
*/
public void setApiKey(String apiKey) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKey(apiKey);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
}
示例9: setApiKeyPrefix
import io.swagger.client.auth.ApiKeyAuth; //导入依赖的package包/类
/**
* Helper method to set API key prefix for the first API key authentication.
*/
public void setApiKeyPrefix(String apiKeyPrefix) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
}
示例10: ApiClient
import io.swagger.client.auth.ApiKeyAuth; //导入依赖的package包/类
public ApiClient() {
httpClient = new OkHttpClient();
verifyingSsl = true;
json = new JSON(this);
/*
* Use RFC3339 format for date and datetime.
* See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14
*/
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// Always use UTC as the default time zone when dealing with date (without time).
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
initDatetimeFormat();
// Be lenient on datetime formats when parsing datetime from string.
// See <code>parseDatetime</code>.
this.lenientDatetimeFormat = true;
// Set default User-Agent.
setUserAgent("Swagger-Codegen/1.0.0/java");
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
authentications.put("access-token", new ApiKeyAuth("header", "access-token"));
authentications.put("client-id", new ApiKeyAuth("header", "client-id"));
authentications.put("merchant-id", new ApiKeyAuth("header", "merchant-id"));
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
}
示例11: 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);
}
示例12: 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;
}
}
}