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签署改装请求?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值