title: Forbidden Exception on accessing AWS Iot using Amazon Cognito
body: <p>I am creating an android application which connects to AWS IoT using Amazon Cognito authentication. I am able to authenticate user successfully and I am able get the credentials.
  While updating the thing shadow using these credentials always return 403 Forbidden Exception. I have tried all my ways to troubleshoot the issue but I found no solutions.</p>
  
  <p>My IAM Policy is:</p>
  
  <pre><code>{
      "Version": "2012-10-17",
      "Statement": [
          {
              "Effect": "Allow",
              "Action": [
                  "iot:GetThingShadow",
                  "iot:UpdateThingShadow",
  
              ],
              "Resource": [
                 "arn:aws:iot:us-west-2:&lt;my_account&gt;:thing/mythingname"
              ]
          }
      ]
  }
  </code></pre>
  
  <p>Android code for connecting endpoint:</p>
  
  <pre><code>userSession= AppHelper.getCurrSession();
  credentialsProvider=new CognitoCachingCredentialsProvider(getApplicationContext(),POOL_ID,REGIONS);
  
      Map&lt;String,String&gt; logins=new HashMap&lt;String, String&gt;();
      logins.put("cognito-idp.us-west-2.amazonaws.com/user_pool_id",userSession.getIdToken().getJWTToken());
  
      credentialsProvider.setLogins(logins);
      iotDataClient=new AWSIotDataClient(credentialsProvider);
  
      iotDataClient.setEndpoint(ENDPOINT);
  </code></pre>
  
  <p>Updating thing shadow:</p>
  
  <pre><code> UpdateThingShadowRequest request=new UpdateThingShadowRequest();
              request.setThingName(thingName);
  
              ByteBuffer payloadBuffer=ByteBuffer.wrap(updateState.getBytes());
              request.setPayload(payloadBuffer);
  
              UpdateThingShadowResult result=iotDataClient.updateThingShadow(request);
  </code></pre>
  
  <p>Any help with this regard would be appreciated. </p>