-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amplify v2 missing migration info #2437
Comments
There is a separate There are helper methods inside Please see the Amplify.API documentation for using API. ApiClientFactory is from the AWS Android SDK, which must be removed to not conflict with Amplify v2. https://docs.amplify.aws/lib/graphqlapi/getting-started/q/platform/android/ |
Hi @tylerjroach , 1.Indeed for configuration in the end I found how to use it. AmplifyConfiguration configuration = AmplifyConfiguration.builder(getConfiguration()) 2.But my big issue is the 2 problem. My generated class contains at least 110 api requests with this format: @com.amazonaws.mobileconnectors.apigateway.annotation.Operation(path = "/com_cards/action", method = "PUT") So that means I need to transform it into: Map<String, String> queryParams = new HashMap<>(); There is a way or a mechanism to make them programmatical from old version to the new version? Or from API Gatway to generate the Android SDK with the format for Amplify V2? |
At this time, there is not an automated method to create a Codegen SDK for AmplifyGateway using the newer Kotlin SDK. However, you can pass a custom Credentials Provider that wraps Amplify v2 into the existing Android Codegen approach as seen here: #2400 (comment) |
Hi, thx for that workaround but that has a weird issue, the refresh token is not automated made. I tried a lot of things to force it but after 1h all my Api requests are falling. Only if I destroy the app and start it again will works. Also I think we need to have this automated method to create a Codegen SDK, for such a large company, I don't think it would be that difficult to make 2 scripts to generate Java and Kotlin code. Thx. |
@lolucosmin I see another report about requests failing after 1 hr. I will try to take a look on my end. It is the responsibility of the custom credentials provider to refresh the token as necessary in the |
@lolucosmin Can you send a code sample of how you are passing your custom credentials provider for API Gateway? |
@tylerjroach Hi, so this my code: MyCredentialsProvider provider = new MyCredentialsProvider(); BFanApiClient.class - generated class from API Gatway. So after I create a new instance of BFanApiClient I use it with observers to execute my api requests. The main idea is to put this provider and client into a singleton class and keep it while the app is running, |
Are you using the MyCredentialsProvider exactly as I had linked? If not, can you provide the code to your provider here. What you have should work. When a request is built, it will use the provided Are you creating requests as necessary, or creating a request, then making the request call after 1 hr. It appears that If you could also initialize Amplify by adding our logging plugin first: |
@tylerjroach I will provide you more details. App flow: 1.In Application class I initialized the Amplify:
2.After continue to initialized ApiClientFactory:
3.Then the app continue to main screen, where there I do some get data from server and right now for test I am using this method:
So as you can see from my client which was initialized I call a specific function: This function is from my generated class from API Gatway and it looks like this: I keep the application open and for an hour everything is ok, if I re-execute that request 100 times it will work, but after an hour exactly when the cognito session expires it stops working. Tomorrow I will add also this: This is my MyCredentialsProvider: public class MyCredentialsProvider implements AWSCredentialsProvider {
} Important: Step 1: - migrate the client.organizationGet to the new format:
Step 2: - run it So after an hour, that with ApiClientFactory is falling and this one with the new structure is working well. |
@tylerjroach did you check my last info? |
@lolucosmin, thank you for the update. Looking over your code this morning, it would still be helpful to see logs posted from It may also be helpful to add your own logging in your |
Closing due to inactivity. Please feel free to open a new bug if you are still facing issues. |
|
Before opening, please confirm:
Language and Async Model
Java
Amplify Categories
REST API
Gradle script dependencies
Environment information
Please include any relevant guides or documentation you're referencing
https://docs.amplify.aws/lib/restapi/getting-started/q/platform/android/
Describe the bug
---Current config---
Right now on my project I am using AWSMobileClient and I want to migrate the project to Amplify v2. I am using also API Gatway, so base on this I have a generated class for all my api requests.
First step for me is to call initialize: AWSMobileClient.getInstance().initialize with a specific configuration created by me.
AWSConfiguration awsConfiguration = new AWSConfiguration(getAWSConfiguration());
AWSMobileClient.getInstance().initialize(AppApplication.getInstance().getApplicationContext(), awsConfiguration, callback);
JSONObject getAWSConfiguration()-I use this because base on flavor some parameters will be changed in that json and I don't take the configuration from a file.
Next step on success result I do this thing:
I create a client with my generated class like this:
client= new ApiClientFactory()
.region("region")
.endpoint("endpoint")
.credentialsProvider("provider")
.build(GeneratedClassFromAPIGatway.class);
-region: eu-west-1
-provider: AWSMobileClient.getInstance()
Until now is very clear and all is working fine.
---Start migrating process---
Amplify.addPlugin(new AWSApiPlugin());
Amplify.addPlugin(new AWSCognitoAuthPlugin());
Amplify.configure(getContext());
---Issues---
Reproduction steps (if applicable)
No response
Code Snippet
// Put your code below this line.
Log output
amplifyconfiguration.json
No response
GraphQL Schema
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: