aws-amplify / aws-sdk-android

AWS SDK for Android. For more information, see our web site:
https://docs.amplify.aws
Other
1.03k stars 551 forks source link

App crashing : Not able to find CognitoUserPoolsSignInProvider #408

Closed kopevgale closed 6 years ago

kopevgale commented 6 years ago

I follow the manual Connecting to Mobile Backend I start him in real phone, non virtual android 6 version my AndroidManifest.xml must contain: <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

I Add dependencies to your app/build.gradle. These libraries enable basic AWS functions, like credentials, and analytics. dependencies { compile ('com.amazonaws:aws-android-sdk-mobile-client:2.6.7@aar') { transitive = true; } }

I Add the following code to the onCreate method of your main or startup activity. This will establish a connection with AWS Mobile. AWSMobileClient is a singleton that will be an interface for your AWS services.

import com.amazonaws.mobile.client.AWSMobileClient;

  public class YourMainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        AWSMobileClient.getInstance().initialize(this).execute();
     }
  }

I get the following error:

`$ adb shell am start -n "com.amazonaws.mobile.samples.mynotes/com.amazonaws.mobile.samples.mynotes.NoteListActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Error while executing: am start -n "com.amazonaws.mobile.samples.mynotes/com.amazonaws.mobile.samples.mynotes.NoteListActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.amazonaws.mobile.samples.mynotes/.NoteListActivity } Error type 3 Error: Activity class {com.amazonaws.mobile.samples.mynotes/com.amazonaws.mobile.samples.mynotes.NoteListActivity} does not exist.

Errors while Launching activity:

`E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.amazonaws.mobile.samples.notes, PID: 22287
                  java.lang.NoClassDefFoundError: Failed resolution of: Lcom/amazonaws/mobile/auth/userpools/CognitoUserPoolsSignInProvider;
                      at com.amazonaws.mobile.client.AWSMobileClient.registerConfigSignInProviders(AWSMobileClient.java:318)
                      at com.amazonaws.mobile.client.AWSMobileClient.fetchCognitoIdentity(AWSMobileClient.java:277)
                      at com.amazonaws.mobile.client.AWSMobileClient.initializeWithBuilder(AWSMobileClient.java:183)
                      at com.amazonaws.mobile.client.AWSMobileClient.access$100(AWSMobileClient.java:72)
                      at com.amazonaws.mobile.client.AWSMobileClient$InitializeBuilder.execute(AWSMobileClient.java:429)
                      at com.amazonaws.mobile.samples.mynotes.NoteListActivity.onCreate(NoteListActivity.java:87)
                      at android.app.Activity.performCreate(Activity.java:6314)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                      at android.app.ActivityThread.-wrap11(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                      at android.os.Handler.dispatchMessage(Handler.java:111)
                      at android.os.Looper.loop(Looper.java:207)
                      at android.app.ActivityThread.main(ActivityThread.java:5728)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
                   Caused by: java.lang.ClassNotFoundException: Didn't find class "com.amazonaws.mobile.auth.userpools.CognitoUserPoolsSignInProvider" on path: DexPathList[[zip file "/data/app/com.amazonaws.mobile.samples.notes-2/base.apk", zip file "/data/app/com.amazonaws.mobile.samples.notes-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.amazonaws.mobile.samples.notes-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.amazonaws.mobile.samples.notes-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.amazonaws.mobile.samples.notes-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.amazonaws.mobile.samples.notes-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.amazonaws.mobile.samples.notes-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.amazonaws.mobile.samples.notes-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.amazonaws.mobile.samples.notes-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.amazonaws.mobile.samples.notes-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.amazonaws.mobile.samples.notes-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.amazonaws.mobile.samples.notes-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.amazonaws.mobile.samples.notes-2/lib/arm, /vendor/lib, /system/lib]]
                      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                      at com.amazonaws.mobile.client.AWSMobileClient.registerConfigSignInProviders(AWSMobileClient.java:318) 
                      at com.amazonaws.mobile.client.AWSMobileClient.fetchCognitoIdentity(AWSMobileClient.java:277) 
                      at com.amazonaws.mobile.client.AWSMobileClient.initializeWithBuilder(AWSMobileClient.java:183) 
                      at com.amazonaws.mobile.client.AWSMobileClient.access$100(AWSMobileClient.java:72) 
                      at com.amazonaws.mobile.client.AWSMobileClient$InitializeBuilder.execute(AWSMobileClient.java:429) 
                      at com.amazonaws.mobile.samples.mynotes.NoteListActivity.onCreate(NoteListActivity.java:87) 
                      at android.app.Activity.performCreate(Activity.java:6314) 
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) 
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519) 
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654) 
                      at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488) 
                      at android.os.Handler.dispatchMessage(Handler.java:111) 
                      at android.os.Looper.loop(Looper.java:207) 
                      at android.app.ActivityThread.main(ActivityThread.java:5728) 
                      at java.lang.reflect.Method.invoke(Native Method) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 
                    Suppressed: java.lang.ClassNotFoundException: com.amazonaws.mobile.auth.userpools.CognitoUserPoolsSignInProvider
                      at java.lang.Class.classForName(Native Method)
                      at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                      at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                            ... 19 more
                   Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
`
`
this is line 87 in NoteListActivity.java : `AWSMobileClient.getInstance().initialize(this).execute();`

this is my NoteListActivity.java :

/*
 * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
 * except in compliance with the License. A copy of the License is located at
 *
 *    http://aws.amazon.com/apache2.0/
 *
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
 * the specific language governing permissions and limitations under the License.
 */
package com.amazonaws.mobile.samples.mynotes;

import android.app.LoaderManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.amazonaws.mobile.samples.mynotes.data.Note;
import com.amazonaws.mobile.samples.mynotes.data.NoteViewHolder;
import com.amazonaws.mobile.samples.mynotes.data.NotesContentContract;

import com.amazonaws.mobile.client.AWSMobileClient;

/**
 * An activity representing a list of Notes. This activity
 * has different presentations for handset and tablet-size devices. On
 * handsets, the activity presents a list of items, which when touched,
 * lead to a {@link NoteDetailActivity} representing
 * item details. On tablets, the activity presents the list of items and
 * item details side-by-side using two vertical panes.
 */
public class NoteListActivity
        extends AppCompatActivity
        implements LoaderManager.LoaderCallbacks<Cursor>
{
    /**
     * The unique identifier for the loader
     */
    private static final int NOTES_LOADER = 10;

    /**
     * The listview
     */
    RecyclerView notesList;

    /**
     * The Add New Note button
     */
    FloatingActionButton addNoteButton;

    /**
     * Whether or not the activity is in two-pane mode, i.e. running on a tablet
     * device.
     */
    private boolean mTwoPane;

    /**
     * Activity lifecycle event handler - called when the activity is first created.
     * @param savedInstanceState the saved state
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        AWSMobileClient.getInstance().initialize(this).execute();

        setContentView(R.layout.activity_note_list);

        // Install the application crash handler.  This is only done on the first activity.
        ApplicationCrashHandler.installHandler();

        // Work out if we are in 2-pane (tablet) mode or not
        mTwoPane = (findViewById(R.id.note_detail_container) != null);

        // Initialize the Toolbar
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        toolbar.setTitle(getTitle());

        // Initialize the floating action button
        addNoteButton = (FloatingActionButton) findViewById(R.id.addNoteButton);
        addNoteButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mTwoPane) {
                    NoteDetailFragment fragment = new NoteDetailFragment();
                    getSupportFragmentManager()
                            .beginTransaction()
                            .replace(R.id.note_detail_container, fragment)
                            .commit();
                } else {
                    Context context = view.getContext();
                    Intent intent = new Intent(context, NoteDetailActivity.class);
                    context.startActivity(intent);
                }
            }
        });

        // Update the ListView with the CursorAdapter
        notesList = (RecyclerView) findViewById(R.id.note_list);
        NotesAdapter adapter = new NotesAdapter(this, null);
        notesList.setAdapter(adapter);

        // Initialize the swipe-to-delete handler
        ItemTouchHelper.SimpleCallback swipeHandler = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
            Drawable background, xMark;
            int xMarkMargin;
            boolean initialized;

            private void initialize() {
                background = new ColorDrawable(Color.RED);
                xMark = ContextCompat.getDrawable(NoteListActivity.this, R.drawable.ic_clear_24dp);
                xMark.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
                xMarkMargin = (int) NoteListActivity.this.getResources().getDimension(R.dimen.ic_clear_margin);
                initialized = true;
            }

            @Override
            public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                return false;
            }

            @Override
            public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
                final NoteViewHolder noteHolder = (NoteViewHolder) viewHolder;
                ((NotesAdapter) notesList.getAdapter()).remove(noteHolder);
            }

            @Override
            public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
                // If the item has already been swiped away, ignore
                if (viewHolder.getAdapterPosition() == -1) return;

                // If not initialized, then do so
                if (!initialized) initialize();

                int vr = viewHolder.itemView.getRight();
                int vt = viewHolder.itemView.getTop();
                int vb = viewHolder.itemView.getBottom();
                int vh = vb - vt;
                int iw = xMark.getIntrinsicWidth();
                int ih = xMark.getIntrinsicWidth();

                background.setBounds(vr + (int)dX, vt, vr, vb);
                background.draw(c);

                int xMarkLeft = vr - xMarkMargin - iw;
                int xMarkRight = vr - xMarkMargin;
                int xMarkTop = vt + (vh - ih)/2;
                int xMarkBottom = xMarkTop + ih;
                xMark.setBounds(xMarkLeft, xMarkTop, xMarkRight, xMarkBottom);
                xMark.draw(c);

                super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
            }
        };
        ItemTouchHelper itemTouchHelper = new ItemTouchHelper(swipeHandler);
        itemTouchHelper.attachToRecyclerView(notesList);

        // Kick off the data loader for the RecyclerView
        getLoaderManager().initLoader(NOTES_LOADER, null, this);
    }

    /**
     * Event handler callback for the loader manager.  Called when creating the loader
     * manager.
     *
     * @param id The ID - should always be NOTES_LOADER in this edition
     * @param args any arguments - should always be null in this edition
     * @return the loader
     */
    @Override
    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        return new CursorLoader(this,
                NotesContentContract.Notes.CONTENT_URI,
                NotesContentContract.Notes.PROJECTION_ALL,
                null,
                null,
                NotesContentContract.Notes.SORT_ORDER_DEFAULT);
    }

    /**
     * Event handler callback for the loader manager.  Called when data has finished loading.
     * @param loader the loader that finished loading
     * @param data a cursor to the data that was loaded
     */
    @Override
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        ((NotesAdapter) notesList.getAdapter()).swapCursor(data);
    }

    /**
     * Event handler callback for the loader manager.  Called when the loader is reset.
     * @param loader the loader that was reset
     */
    @Override
    public void onLoaderReset(Loader<Cursor> loader) {
        ((NotesAdapter) notesList.getAdapter()).swapCursor(null);
    }

    /**
     * The NotesAdapter is a data provider for linking the notes content provider to the UI.
     */
    private class NotesAdapter extends RecyclerView.Adapter<NoteViewHolder> {
        Cursor dataCursor;
        Context context;

        NotesAdapter(Context mContext, Cursor cursor) {
            dataCursor = cursor;
            context = mContext;
        }

        @Override
        public NoteViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.note_list_content, parent, false);
            return new NoteViewHolder(view);
        }

        /**
         * The main part of the NotesAdapter - this is called once for each element in the
         * list of data that is returned.
         * @param holder the ViewHolder (which is a NoteViewHolder) for the record
         * @param position the position in the list.
         */
        @Override
        public void onBindViewHolder(final NoteViewHolder holder, int position) {
            dataCursor.moveToPosition(position);
            Note note = Note.fromCursor(dataCursor);
            holder.setNote(note);

            // Install a click-handler for clicking on the row
            holder.getView().setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Bundle arguments = new Bundle();
                    arguments.putString(NoteDetailFragment.ARG_ITEM_ID, holder.getNote().getNoteId());
                    if (mTwoPane) {
                        NoteDetailFragment fragment = new NoteDetailFragment();
                        fragment.setArguments(arguments);
                        getSupportFragmentManager()
                                .beginTransaction()
                                .replace(R.id.note_detail_container, fragment)
                                .commit();
                    } else {
                        Context context = v.getContext();
                        Intent intent = new Intent(context, NoteDetailActivity.class);
                        intent.putExtras(arguments);
                        context.startActivity(intent);
                    }
                }
            });
        }

        @Override
        public int getItemCount() {
            return (dataCursor == null) ? 0 : dataCursor.getCount();
        }

        /**
         * Used to support the loader framework for loading data
         * @param cursor the new cursor
         * @return the old cursor
         */
        Cursor swapCursor(Cursor cursor) {
            if (dataCursor == cursor) {
                return null;
            }
            Cursor oldCursor = dataCursor;
            this.dataCursor = cursor;
            if (cursor != null) {
                this.notifyDataSetChanged();
            }
            return oldCursor;
        }

        /**
         * Remove the element in the list.
         * @param holder the viewholder to delete
         */
        void remove(final NoteViewHolder holder) {
            if (mTwoPane) {
                // Check to see if the current fragment is the record we are deleting
                Fragment currentFragment = NoteListActivity.this
                        .getSupportFragmentManager()
                        .findFragmentById(R.id.note_detail_container);
                if (currentFragment instanceof NoteDetailFragment) {
                    String deletedNote = holder.getNote().getNoteId();
                    String displayedNote = ((NoteDetailFragment) currentFragment).getNote().getNoteId();
                    if (deletedNote.equals(displayedNote)) {
                        getSupportFragmentManager().beginTransaction().remove(currentFragment).commit();
                    }
                }
            }

            // Remove the item from the database
            ContentResolver resolver = getContentResolver();
            int position = holder.getAdapterPosition();
            Uri itemUri = NotesContentContract.Notes.uriBuilder(holder.getNote().getNoteId());
            int count = resolver.delete(itemUri, null, null);
            if (count > 0) {
                notifyItemRemoved(position);
            }
        }
    }
}
mutablealligator commented 6 years ago

Sorry for the inconvenience caused.

This issue happens because you have added CognitoUserPool in the awsconfiguration.json file but not added the dependencies for userpools in the build.gralde

AWSMobileClient errored out because it was not able to find CognitoUserPoolsSignInProvider class which comes from aws-android-sdk-auth-userpools package.

Can you check if the awsconfiguration.json file has CognitoUserPool in it? Have you created a UserPool (Amazon Cognito UserPools) in the backend console?

If you add the dependencies as follows, the AWSMobileClient will be able to proceed in initializing.

https://docs.aws.amazon.com/aws-mobile/latest/developerguide/add-aws-mobile-user-sign-in.html#set-up-email-and-password

dependencies {
     // Mobile Client for initializing the SDK
     compile ('com.amazonaws:aws-android-sdk-mobile-client:2.6.+@aar') { transitive = true; }

     // Cognito UserPools for SignIn
     compile 'com.android.support:support-v4:24.+'
     compile ('com.amazonaws:aws-android-sdk-auth-userpools:2.6.+@aar') { transitive = true; }

     // Sign in UI Library
     compile 'com.android.support:appcompat-v7:24.+'
     compile ('com.amazonaws:aws-android-sdk-auth-ui:2.6.+@aar') { transitive = true; }
}
kopevgale commented 6 years ago

this is my awsconfiguration.json

{
  "UserAgent": "MobileHub/1.0",
  "Version": "1.0",
  "CredentialsProvider": {
    "CognitoIdentity": {
      "Default": {
        "PoolId": "*******",
        "Region": "us-east-2"
      }
    }
  },
  "IdentityManager": {
    "Default": {}
  },
  "PinpointAnalytics": {
    "Default": {
      "AppId": "**********",
      "Region": "us-east-1"
    }
  },
  "PinpointTargeting": {
    "Default": {
      "Region": "us-east-1"
    }
  }
}
mutablealligator commented 6 years ago

For security reasons, I modified your awsconfiguration.json to not expose the pool id and app id. Do you mean to say that your app crashes even if CognitoUserPool is not present in the awsconfiguration.json? Do you see a crash with the above contents?

kopevgale commented 6 years ago

pool name must match the name of the application?

mutablealligator commented 6 years ago

Case-1: If you want to add User SignIn feature to your app with Amazon Cognito UserPools, follow the steps here: Setup Backend for UserPools and then Add UserPools dependencies to your app. If you follow all the steps laid out in the above two sections, you will be able to add user sign in feature to your app.

Case-2: If you do not intend to add User SignIn feature in your app, you can skip adding CognitoUserPool information in awsconfiguration.json.

Case-3: You have added CognitoUserPool in awsconfiguration.json but not imported the appropriate dependencies in gradle, which tells AWSMobileClient that you are planning to integrate UserPools in your application.Since the dependencies are not available, the AWSMobileClient throws an exception.

The exception is thrown when you are in case-3.

kopevgale commented 6 years ago

word " activity_authenticator " in line "setContentView(R.layout.activity_authenticator);" is red. i see "cannot resolve symbol activity authentificator" . How i can fix it? this is my AuthenticatorActivity.java:

package com.amazonaws.mobile.samples.mynotes;

import android.app.Activity;
import android.os.Bundle;

import com.amazonaws.mobile.auth.ui.SignInUI;
import com.amazonaws.mobile.client.AWSMobileClient;
import com.amazonaws.mobile.client.AWSStartupHandler;
import com.amazonaws.mobile.client.AWSStartupResult;

import android.app.Activity;

/**
 * Created by Genius on 10.02.2018.
 */

public class AuthenticatorActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_authenticator);

        AWSMobileClient.getInstance().initialize(this, new AWSStartupHandler() {
            @Override
            public void onComplete(AWSStartupResult awsStartupResult) {
                SignInUI signin = (SignInUI) AWSMobileClient.getInstance().getClient(AuthenticatorActivity.this, SignInUI.class);
                signin.login(AuthenticatorActivity.this, NoteListActivity.class).execute();
            }
        }).execute();
    }
}
}
mutablealligator commented 6 years ago

When you created an activity in Android Studio with the name "AuthenticatorActivity", it would create the respective layout/xml file in your resources folder with the name activity_authenticator. Can you check if you have this file? Otherwise, you should create a new activity with this name and copy the code in your onCreate and ensure you have the corresponding layout/xml file associated with your activity.

mutablealligator commented 6 years ago

@kopevgale Just checking if you are unblocked from this issue or are there any other issues pending here? Please let us know. Thank you!

kopevgale commented 6 years ago

@kvasukib, sanx you very mutch, this work. I also configure sdk in build.gradle (module app):


    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.amazonaws.mobile.samples.notes"
        minSdkVersion 23
        targetSdkVersion 26```
minbi commented 6 years ago

Re-open or create another issue if further discussion is required.

aswinkumarpopuri commented 5 years ago

@kopevgale hi, I am getting this issue in my Andriod app, I do have the awsconfiguration.Json file in a raw folder, and I do have all the dependencies in my build.gradle that you mentioned above.

W/AWSMobileClient: getCredentials: Failed to getCredentials from Cognito Identity com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Unauthenticated access is not supported for this identity pool. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: NotAuthorizedException; Request ID: 5dd821b5-1826-11e9-96c7-ddcc1850988a)

I couldn't can you let me know when do i have these type of exceptions?

mutablealligator commented 5 years ago

@aswinkumarpopuri Have you enabled "Access to Unauthenticated Identities" in your Cognito Identity Pool?

aswinkumarpopuri commented 5 years ago

In the Aws console or thorugh the app?, how can I provide access for unauthenticated users through the code ?

Thanks in advance

mutablealligator commented 5 years ago

In the AWS console. This is an option that can be found in the Cognito Identity pool settings.

mutablealligator commented 5 years ago

@kopevgale We have added new features to AWSMobileClient which will solve your use-case.

Note: The existing methods of AWSMobileClient are deprecated and will be removed in a future minor version. AWSMobileClient now takes a dependency on AWSCognitoIdentityProvider(Cognito User Pools SDK) package to offer integration with CognitoUserPools. When using the new drop-in UI, AWSAuthUI and Social sign-in features continue to be pluggable dependencies for AWSMobileClient.

All documentation is now centralized at https://aws-amplify.github.io/

Please upgrade to the latest version (2.10.1) to get the latest updates.