title: AcquireTokenSilent() throws Failed to acquire token silently. Call method AcquireToken error
body: <p>I have a native client application and I'm trying to use AcquireTokenSilent() so there isn't a prompt for user creds. However, after many (many) attempts, I'm just lost on where the problem is.</p>
  
  <p>I have created my own PrivateTokenCacheClass which is inherited from TokenCache class. </p>
  
  <p>Here's my code:</p>
  
  <pre><code> public class PrivateTokenCacheClass : TokenCache
      {
          public string CacheFilePath = @"C:\Users\blahblah\Desktop\token.txt";
  
          public AADTokenCache()
          {
              CacheFilePath = @"C:\Users\blahblah\Desktop\token.txt";
              this.BeforeAccess = BeforeAccessNotification;
              this.AfterAccess = AfterAccessNotification;
          }
  
          public void BeforeAccessNotification(TokenCacheNotificationArgs args)
          {
              this.Deserialize(File.ReadAllBytes(CacheFilePath));            
          }
          public void AfterAccessNotification(TokenCacheNotificationArgs args)
          {
              if(this.HasStateChanged)
              {
                  File.WriteAllBytes(CacheFilePath, this.Serialize());
                  this.HasStateChanged = false;
              }            
          }
  
      }
  </code></pre>
  
  <p>Now, in my AcquireToken method, I do this:</p>
  
  <pre><code> private static string acquireAuthToken()
          {
              PrivateTokenCacheClass pvtCache = new PrivateTokenCacheClass();
  
             AuthenticationContext authContext = new AuthenticationContext(authority, pvtCache);
  
              string token = authContext.AcquireTokenSilent(resourceUri, clientID, UserIdentifier.AnyUser).AccessToken.ToString();
          }
  </code></pre>
  
  <p>The token.txt file contains the token (in plain text) that I got from previously (10 mins ago) using this call:</p>
  
  <pre><code>string token = authContext.AcquireToken(resourceUri, clientID, redirectUri).AccessToken.ToString();
  </code></pre>
  
  <p>Any help would be highly appreciated!</p>