Skip to content
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

AWSAppSyncClient to perform API calls, using ClientFactory.java. Error in logcat reads "Please check the AppSync configuration in awsconfiguration.json." #277

Open
tonyyhliu opened this issue May 11, 2020 · 0 comments
Labels
question General question

Comments

@tonyyhliu
Copy link

Hi,
I am using AWS Amplify and came across some issues. My app logs in perfectly and on restarting the app, the UserState is SIGNED_IN
But when I try to build an appsync client it gives the following exception:

Please check the AppSync configuration in awsconfiguration.json.

I've copied the code from the AWS Amplify Docs, and my code is the following in ClientFactory.java:

public static synchronized void init(final Context context) {
if (client == null) {
final AWSConfiguration awsConfiguration = new AWSConfiguration(context);
client = AWSAppSyncClient.builder()
.context(context)
.awsConfiguration(awsConfiguration)
.cognitoUserPoolsAuthProvider(new CognitoUserPoolsAuthProvider() {
@OverRide
public String getLatestAuthToken() {
try {
return AWSMobileClient.getInstance().getTokens().getIdToken().getTokenString();
} catch (Exception e){
Log.e("APPSYNC_ERROR", e.getLocalizedMessage());
return e.getLocalizedMessage();
}
}
}).build();
}
}

My logcat has the following messages:

Caused by: java.lang.RuntimeException: Please check the AppSync configuration in awsconfiguration.json. at com.amazonaws.mobileconnectors.appsync.AWSAppSyncClient$Builder.build(AWSAppSyncClient.java:485) at com.example.events.ClientFactory.init(ClientFactory.java:31) at com.example.events.MainActivity.onCreate(MainActivity.java:69) at android.app.Activity.performCreate(Activity.java:7136) at android.app.Activity.performCreate(Activity.java:7127) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:6669)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)  Caused by: java.lang.RuntimeException: Found conflicting AuthMode. Should be API_KEY but you selected AMAZON_COGNITO_USER_POOLS

My app crashes on start and I'm not quite sure how to fix this. Any advice would be greatly appreciated!

@gpanshu gpanshu added the pending-triage Issue is pending triage label May 1, 2023
@tylerjroach tylerjroach added question General question and removed pending-triage Issue is pending triage labels Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question General question
Projects
None yet
Development

No branches or pull requests

3 participants