title: API authentication failure due to Invalid Credentials : wso2 IOT server
body: <p>I am using siddhi on android and have registered emulator with IOT server, but the issue is that sometimes it works but sometimes it gives an error like this</p>
  
  
  
  <pre class="lang-sh prettyprint-override"><code>[2018-02-08 16:24:21,331] [IoT-Core]  WARN - {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler} API authentication failure due to Invalid Credentials
  [2018-02-08 16:24:21,331] [IoT-Core]  WARN - {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler} API authentication failure due to Invalid Credentials
  [2018-02-08 16:24:21,331] [IoT-Core]  WARN - {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler} API authentication failure due to Invalid Credentials
  [2018-02-08 16:24:21,334] [IoT-Core]  WARN - {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler} API authentication failure due to Invalid Credentials
  [2018-02-08 16:24:21,399] [IoT-Core]  INFO - {org.wso2.carbon.apimgt.gateway.handlers.security.APIKeyValidator} Invalid OAuth Token : Access Token c2fbbf1c-437f-347b-a233-0cfe3d58156c expired.
  [2018-02-08 16:24:21,399] [IoT-Core]  WARN - {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler} API authentication failure due to Invalid Credentials
  [2018-02-08 16:24:21,423] [IoT-Core] ERROR - {org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl} Invalid OAuth Token : Invalid access token
  [2018-02-08 16:24:21,426] [IoT-Core]  WARN - {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler} API authentication failure due to Invalid Credentials
  [2018-02-08 16:24:21,434] [IoT-Core]  INFO - {org.wso2.carbon.apimgt.gateway.handlers.security.APIKeyValidator} Invalid OAuth Token : Access Token c2fbbf1c-437f-347b-a233-0cfe3d58156c expired.
  [2018-02-08 16:24:21,434] [IoT-Core]  WARN - {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler} API authentication failure due to Invalid Credentials
  [2018-02-08 16:24:21,443] [IoT-Core] ERROR - {org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl} Invalid OAuth Token : Invalid access token
  [2018-02-08 16:24:21,445] [IoT-Core]  WARN - {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler} API authentication failure due to Invalid Credentials
  </code></pre>
  
  <p>my guess is that it is happening because each time I launch emulator the credentials change for the phone</p>
  
  <p>It shows me that agent is not connected</p>
  
  <p><a href="https://i.stack.imgur.com/F5c2x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F5c2x.png" alt="enter image description here"></a></p>
  
  <p>but Agent shows that sync was ok</p>
  
  <p><a href="https://i.stack.imgur.com/Jyv5Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jyv5Q.png" alt="enter image description here"></a></p>
  
  <p>what am I doing wrong?</p>