title: Unauthorized, The input authorization token can't serve the request
body: <p>I am trying to obtain documentdbclient using the resourcetokens. I have a redis cluster with key as user identity and value as the resourcetoken. 
  I have a service that uses master key to generate resourcetokens for the user and updates them in Redis. I am using the below code to create resource token in my master service</p>
  
  <pre><code>  ResourceResponse&lt;Permission&gt; readPermissions = documentClient.readPermission("/dbs/customerdb/users/mobileuser/permissions/readperm", null);
          String accessToken=permission.getToken();
  DocumentClient documentClient = new DocumentClient(HOST, MASTER_KEY,
                       ConnectionPolicy.GetDefault(), ConsistencyLevel.Session);
  </code></pre>
  
  <p>Then i use below code to get resourcetoken and store it in redis</p>
  
  <pre><code>jedis.put("Client_1",readPermissions .getResource().getToken());
  </code></pre>
  
  <p>Now, at client side when i try to create documentClient using the resourcetoken</p>
  
  <pre><code>DocumentClient manageClient = new DocumentClient(HOST,  jedis.get("Client_1"),ConnectionPolicy.GetDefault(), ConsistencyLevel.Session);
  </code></pre>
  
  <p>I get logs stating unauthorized and following that the error</p>
  
  <pre><code>Unauthorized, The input authorization token can't serve the request
  </code></pre>
  
  <p>I have created a user called mobileuser on database customerdb and permission with mode PermissionMode.Read on collection customers</p>
  
  <p>I changed my code to be very sure that the tokens are not getting expired but still getting error</p>
  
  <pre><code>  java.lang.IllegalStateException: com.microsoft.azure.documentdb.DocumentClientException: The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used. Server used the following payload to sign: 'get
  </code></pre>
  
  <p>colls
  dxhxakm3caa=
  mon, 05 jun 2017 08:56:40 gmt</p>
  
  <p>below id the code that i used to get the token </p>
  
  <pre><code>    ResourceResponse&lt;Permission&gt; permissions=documentClient.readPermission("/dbs/customerdd/users/mobileuser/permissions/readperm", null);
      System.out.println(permissions.getResource().getResourceLink());
      DocumentClient managedClient=new DocumentClient(HOST,permissions.getResource().getToken(), ConnectionPolicy.GetDefault(), ConsistencyLevel.Session);
      FeedResponse&lt;Document&gt; response = managedClient.queryDocuments(collection.getResource().getSelfLink(), "SELECT customers.source FROM customers where customers.source='direct-mail'", null);
      Iterator&lt;Document&gt; itr = response.getQueryIterator();
      while(itr.hasNext()){
          Document doc=itr.next();
          System.out.println(doc.get("source"));
      }
  </code></pre>
  
  <p>Any pointer will be of a great help</p>