title: com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Invalid login token. Can't pass in a Cognito token
body: <p>I am using developer authentication in my android app. After successful login, the server sends the client the <code>Cognito</code> token. The intention of this token is to get access to <code>Amazon S3</code> for uploading images.</p>
  <p>I have created a sample project here: <a href="https://github.com/abdullahumer/TestAWSCognito" rel="nofollow noreferrer">TestAWSCognito</a></p>
  <p>Here is the snippet code where I am trying to create AmazonS3Client:</p>
  <pre><code>String identityPoolId = &quot;eu-west-1:289fd4a0-2236-4ff4-9c2b-61c93e60bf0a&quot;;
  
  AmazonS3Client testClient = null;
  
  Map&lt;String, String&gt; loginsMap = new HashMap&lt;&gt;();
  loginsMap.put(&quot;cognito-identity.amazonaws.com&quot;, &quot;eyJraWQiOiJldS13ZXN0LTExIiwidHlwIjoiSldTIiwiYWxnIjoiUlM1MTIifQ.eyJzdWIiOiJldS13ZXN0LTE6MjkyM2IxYWQtNGNiYS00ZTFmLWEyY2YtZGIyNDVmM2Q3NWJiIiwiYXVkIjoiZXUtd2VzdC0xOjI4OWZkNGEwLTIyMzYtNGZmNC05YzJiLTYxYzkzZTYwYmYwYSIsImFtciI6WyJhdXRoZW50aWNhdGVkIiwiZ3JhcGhxbC5oYXJhaiIsImdyYXBocWwuaGFyYWo6ZXUtd2VzdC0xOjI4OWZkNGEwLTIyMzYtNGZmNC05YzJiLTYxYzkzZTYwYmYwYTo1NjI4NDAiXSwiaXNzIjoiaHR0cHM6Ly9jb2duaXRvLWlkZW50aXR5LmFtYXpvbmF3cy5jb20iLCJleHAiOjE1NDUxNDgzMTYsImlhdCI6MTU0NTA2MTkxNn0.V-iZeAQdsdMb9LkzYNucka5PEYRMBKKTGm5CzZIJYg8Z5ehcq562JbXGJWr7Yea-w2APsbpVxgP8EjHxSLjsMggk2FdVd-m8YhNFwBYL91oph-wFiAIxLVginD3t3_EhmkPduXZgM1mwH1_yNsGqpBY4nr15cgjqLvfyb4t-QJADFFyjd2qpIUoNzU2EQ5ypEKmbVdgOeLCIe6a-L09yzO-M1xdC0Onc8fs5ELOISR8FA5YFJYIgyqfSz9wDmz929rmCV9EjFdNC3Jd_hSC_Ofp6NYjiW1HRTU0a2C3Z3FCNJFzKppQSUt78MWrJblhHJSEboeMoKhzxmkA0VPgNjg&quot;);
  
  
  CognitoCredentialsProvider cognitoCredentialsProvider = new CognitoCachingCredentialsProvider(getApplicationContext(), identityPoolId, Regions.EU_WEST_1);
  cognitoCredentialsProvider.setLogins(loginsMap);
  
  try {
      AmazonS3Client testClient = new AmazonS3Client(cognitoCredentialsProvider.getCredentials());
  
      if (testClient != null) {
          return testClient;
      }
  }
  catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>
  <p>The <code>token</code> and <code>identityPoolId</code> are still valid.</p>
  <p>When creating the <code>AmazonS3Client</code> it returns an exception: <code>com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Invalid login token. Can't pass in a Cognito token. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: NotAuthorizedException; Request ID: af373152-0452-11e9-b8c4-c3f49006c33b)</code></p>
  <p>Any help would be appreciated. Thanks!</p>