api网关 android,如何通过Android上的retrofit2使用Cognito Credentials调用API网关?
我在我的Android應用程序中使用retrofit2進行任何http / rest調用.現在我需要調用
Amazon AWS API Gateway生成的api.
AWS文檔say我應該生成客戶端代碼拋出API網關控制臺并使用類ApiClientFactory來構建請求:
ApiClientFactory factory = new ApiClientFactory();
// Use CognitoCachingCredentialsProvider to provide AWS credentials
// for the ApiClientFactory
AWSCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
context, // activity context
"identityPoolId", // Cognito identity pool id
Regions.US_EAST_1 // region of Cognito identity pool
};
factory.credentialsProvider(credentialsProvider);
// Create an instance of your SDK (this should come from the generated code).
final MyApiClient client = factory.build(MyApiClient.class);
// Invoke a method (e.g., 'parentPath1Get(param1,body)') exposed by your SDK.
// Here the method's return type is OriginalModel.
OriginalModel output = client.parentPath1Get(param1,body);
// You also have access to your API's models.
OriginalModel myModel = new OriginalModel();
myModel.setStreetAddress(streetAddress);
myModel.setCity(city);
myModel.setState(state);
myModel.setStreetNumber(streetNumber);
myModel.setNested(nested);
myModel.setPoBox(poBox);
相反,我想像改造那樣定義API:使用我編寫的接口,將其連接到RxJava,OkHttp等……
我的問題是:如何使用Cognito Identity Provider簽署改裝請求?
總結
以上是生活随笔為你收集整理的api网关 android,如何通过Android上的retrofit2使用Cognito Credentials调用API网关?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql的存储过程放在哪里_mysql
- 下一篇: mysql筛选两个表有相同项的数据库_用