title: Azure API App - Client Flow Authentication in Windows 10 Universal App
body: <p>Question about Azure API App with Authentication (client flow) and Windows 10 Universal App. 
  We are having issues with reusing the User's Access Token to call the gateway and api app. After the user has logged in we grab the 
  AuthenticationToken from AppServiceClient CurrentUser and save it as PasswordCredentials for reuse.</p>
  
  <p>From the example Cunsume an API app in Azure App Service from a .NET client (<a href="https://azure.microsoft.com/en-us/documentation/articles/app-service-api-dotnet-consume/" rel="nofollow">https://azure.microsoft.com/en-us/documentation/articles/app-service-api-dotnet-consume/</a>) 
  there is an example at the bottom, but cant get the Access Token to work, we get UnAuthorized. Is there any other examples out there showing how to reuse Access Token (Client Flow) or have any done the same as I'm trying ??</p>
  
  <p>This does not work</p>
  
  <pre><code>var userID = credential.UserName;
  
  var appServiceClient = new AppServiceClient(GATEWAY);
  
  var providerAccessTokenJSON = new JObject();
  
  providerAccessTokenJSON["access_token"] = vault.Retrieve(AUTH_PROVIDER,userID).Password;
  
  var appServiceUser = await appServiceClient.LoginAsync(AUTH_PROVIDER, providerAccessTokenJSON);
  
  var vAPI = appServiceClient.CreateJCBSApiApp();
  
  var vSol = vAPI.Solutions.Get();
  
  foreach (var s in vSol)
  {
      var vID = s.ID;
      var vText = s.Title;
  }
  </code></pre>
  
  <p>Following the server-wide example works fine, I just want to reuse the token as described as client-flow in Azure Tutorial. </p>
  
  <p>--Update--</p>
  
  <p>This is my auth method and storing User Token</p>
  
  <p>Hi, thanks for taking the time to answer. Yes, the token is in the credentials store and I compared it and was the same. Im modern if I'm using the wrong Access Token. </p>
  
  <pre><code>private async Task&lt;IAppServiceUser&gt; AuthenticateAsync()
          {
  
              await _appServiceClient.Logout();
  
              while (_appServiceClient.CurrentUser == null)
              {
                  await _appServiceClient.LoginAsync(AUTH_PROVIDER,false);
              }
  
              var vUserID = _appServiceClient.CurrentUser;
              credential = new PasswordCredential(AUTH_PROVIDER,
                              vUserID.UserId, vUserID.AuthenticationToken.ToString());
              vault.Add(credential);
  
              return _appServiceClient.CurrentUser;
          }
  </code></pre>
  
  <p>Thanks</p>