title: What is the proper way to work with the OneDrive API?
body: <p>I want to interact with OneDrive in my WinForms application. Sadly, the Azure quick start samples do not include WinForms, just UWD.</p>
  <p>The flow on what I have to do is consistent, namely given my <code>Client ID</code>, I have to obtain an <code>Authentication Code</code>. Given the authentication code, I can then obtain an <code>Access Code</code>, which will allow me to interact in a RESTful way with the <code>OneDrive</code> API. My plan is to have the authentication piece go in a <code>.Net Framework Library</code> and the file IO calls will go in another library that has no user interface access, as it will go in a Windows Service. I would pass the Access Token to the service.</p>
  <pre><code>AADSTS50059: No tenant-identifying information found in either the request or implied by any provided credentials.
  </code></pre>
  <p>This error corresponds to the following code fragment that I lifted from the sample .Net Core daemon quick start code.</p>
  <p>Note: I was playing around with <code>Scopes</code> as I kept receiving scope errors and I saw one article, whose link I should have kept, which stated to use the API and default scope.</p>
  <pre><code>public bool GetRestAuthenticationToken(out string tokenAuthentication)
      {
          tokenAuthentication = null;
          try
          {
              IConfidentialClientApplication app;
              app = ConfidentialClientApplicationBuilder.Create(Authenticate.AppClientId)
                                                        .WithClientSecret(Authenticate.AppClientSecret)
                                                        .WithAuthority(new Uri(@&quot;https://login.microsoftonline.com/common/oauth2/nativeclient&quot;))
                                                        .Build();
  
  
              string scope = $&quot;onedrive.readwrite offline_access&quot;;
              System.Collections.Generic.List&lt;string&gt; enumScopes = new System.Collections.Generic.List&lt;string&gt;();
              enumScopes.Add(&quot;api://&lt;GUID&gt;/.default&quot;);
              //enumScopes.Add(Authenticate.Scopes[1]);
              var result = Task.Run(async () =&gt; await app.AcquireTokenForClient(enumScopes).ExecuteAsync()).Result;
              ...
          }
          ...
  }
  </code></pre>
  <p>I believe that I have my application configured properly now on Azure, but am not 100% positive.</p>
  <p>API Permissions:</p>
  <p><a href="https://i.stack.imgur.com/XXYyr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XXYyr.png" alt="Registered App on Azure Portal Showing API Permissions" /></a></p>
  <p>Authentication:</p>
  <ul>
  <li>Desktop Applications: <a href="https://login.microsoftonline.com/common/oauth2/nativeclient" rel="nofollow noreferrer">https://login.microsoftonline.com/common/oauth2/nativeclient</a></li>
  <li>Desktop Applications: <a href="https://login.live.com/oauth20_desktop.srf" rel="nofollow noreferrer">https://login.live.com/oauth20_desktop.srf</a></li>
  <li>Implicit Grants: Access <code>tokens</code> &amp; <code>ID tokens</code></li>
  <li>Live SDK support (Yes)</li>
  <li>Default client type (Yes)</li>
  </ul>
  <p>Others:</p>
  <ul>
  <li>I do have a client secret and kept note of all the Overview <code>GUIDs</code></li>
  </ul>
  <p><a href="https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/graph-oauth?view=odsp-graph-online" rel="nofollow noreferrer">Microsoft Doc 1</a></p>
  <p>I tried several different URLs, but only the one not commented out works with the fragment above, but throws the referenced error.</p>
  <pre><code>            //string redirect_uri = @&quot;https://www.myapp.com/auth&quot;;
              //string redirect_uri = &quot;https://login.live.com/oauth20_desktop.srf&quot;;
              string url = @&quot;https://login.microsoftonline.com/common/oauth2/nativeclient&quot;;
              //string url = $&quot;https://login.live.com/oauth20_authorize.srf?client_id={appClientId}&amp;scope={scope}&amp;response_type=code&amp;redirect_uri={redirect_uri}&quot;;
              //string url = $&quot;https://login.microsoftonline.com/common/oauth2/v2.0/authorize?&quot; +
              //                $&quot;client_id={Authenticate.AppClientId}&amp;&quot; +
              //                $&quot;scope={scope}&amp;&quot; +
              //                $&quot;response_type=token&amp;&quot; +
              //                $&quot;redirect_uri={redirect_uri}&quot;;
  </code></pre>
  <p>The goal is the same, namely to obtain an access token that I can use with <code>RESTful</code> calls to work with files and/or directories on OneDrive, e.g.</p>
  <pre><code>            System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
              client.GetAsync(...);
  </code></pre>