<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Net Core 6.0 compatibility?  Getting OAuth2Exception: invalid_grant for ProcessCodeFlowAsync... in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Net-Core-6-0-compatibility-Getting-OAuth2Exception-invalid-grant/m-p/588896#M27428</link>
    <description>&lt;P&gt;What does your &lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/Overload_Dropbox_Api_DropboxOAuth2Helper_GetAuthorizeUri.htm" target="_blank" rel="noopener"&gt;GetAuthorizeUri&lt;/A&gt; call look like? Your GetAuthorizeUri configuration needs to match your &lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/Overload_Dropbox_Api_DropboxOAuth2Helper_ProcessCodeFlowAsync.htm" target="_blank" rel="noopener"&gt;ProcessCodeFlowAsync&lt;/A&gt; configuration. For example, if you passed a redirectUri to GetAuthorizeUri, you need to also pass that same redirectUri to ProcessCodeFlowAsync. See &lt;A href="https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Examples/SimpleBlogDemo/Controllers/HomeController.cs#L197" target="_self"&gt;this sample code&lt;/A&gt; as an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You mentioned using a redirect URI, but if you're not passing it to ProcessCodeFlowAsync in this code, that could cause this error.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Apr 2022 19:57:42 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2022-04-06T19:57:42Z</dc:date>
    <item>
      <title>Net Core 6.0 compatibility?  Getting OAuth2Exception: invalid_grant for ProcessCodeFlowAsync...</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Net-Core-6-0-compatibility-Getting-OAuth2Exception-invalid-grant/m-p/588883#M27427</link>
      <description>&lt;P&gt;Trying to port a Windows .NET Standard to .NET Core 6.0 using Blazor Server.&amp;nbsp; I've got the old application running just fine and I'm able to get the initial Authorization Code.&amp;nbsp; Trying to pass that along with the key and secret, etc... and I get:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;OAuth2Exception: invalid_grant
Dropbox.Api.DropboxOAuth2Helper.ProcessCodeFlowAsync(string code, string appKey, string appSecret, string redirectUri, HttpClient client, string codeVerifier)
docket2022.Pages.AuthDbxToken.ProcessDropboxCallback(string AuthCode) in AuthDbxToken.razor&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I've made sure all the variables are passing by checking a console....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt; Uri uri = new Uri(NavManager.Uri);
        Console.WriteLine("URI Absolute: " + uri.AbsoluteUri);
        Console.WriteLine("AuthCode: " + AuthCode);
        Console.WriteLine("ApiKeyString: " + ApiKeyString);
        Console.WriteLine("ApiSecretString: " + ApiSecretString);
        Console.WriteLine("Return URL: " + theState);
        State.dbxToken = "Auth Code: " + AuthCode.ToString();
        Console.WriteLine("-------------------------DropboxOAuth2Helper AuthDbxToken.razor--------------------");
        OAuth2Response response = await DropboxOAuth2Helper.ProcessCodeFlowAsync(AuthCode, ApiKeyString, ApiSecretString, theState, null, null);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course I added a localhost redirect URI for my new project.&amp;nbsp; What is strange is that scope, keys, secrets, etc.... is the same but the .NET Core version keeps getting this error.&amp;nbsp; I've looked everywhere but I can't see up or down if there has been success or failure with .NET Core 6.0.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 12:57:11 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Net-Core-6-0-compatibility-Getting-OAuth2Exception-invalid-grant/m-p/588883#M27427</guid>
      <dc:creator>Tech Dev Oldsmar</dc:creator>
      <dc:date>2022-04-26T12:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Net Core 6.0 compatibility?  Getting OAuth2Exception: invalid_grant for ProcessCodeFlowAsync...</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Net-Core-6-0-compatibility-Getting-OAuth2Exception-invalid-grant/m-p/588896#M27428</link>
      <description>&lt;P&gt;What does your &lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/Overload_Dropbox_Api_DropboxOAuth2Helper_GetAuthorizeUri.htm" target="_blank" rel="noopener"&gt;GetAuthorizeUri&lt;/A&gt; call look like? Your GetAuthorizeUri configuration needs to match your &lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/Overload_Dropbox_Api_DropboxOAuth2Helper_ProcessCodeFlowAsync.htm" target="_blank" rel="noopener"&gt;ProcessCodeFlowAsync&lt;/A&gt; configuration. For example, if you passed a redirectUri to GetAuthorizeUri, you need to also pass that same redirectUri to ProcessCodeFlowAsync. See &lt;A href="https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Examples/SimpleBlogDemo/Controllers/HomeController.cs#L197" target="_self"&gt;this sample code&lt;/A&gt; as an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You mentioned using a redirect URI, but if you're not passing it to ProcessCodeFlowAsync in this code, that could cause this error.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 19:57:42 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Net-Core-6-0-compatibility-Getting-OAuth2Exception-invalid-grant/m-p/588896#M27428</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-04-06T19:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Net Core 6.0 compatibility?  Getting OAuth2Exception: invalid_grant for ProcessCodeFlowAsync...</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Net-Core-6-0-compatibility-Getting-OAuth2Exception-invalid-grant/m-p/588904#M27430</link>
      <description>&lt;P&gt;That was it.&amp;nbsp; Thank you! For reference if anyone is doing this in Blazor-Server (code thinned out to pertinent issue):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;@page "/dbxAuth"
@using System.Runtime.InteropServices
@using System.Threading.Tasks
@using Dropbox.Api
@inject NavigationManager NavManager

@code
{
    public async Task ProcessDropboxCallback(string AuthCode)
{
// HERE IS WHERE I FIXED THE ISSUE
        var uriBuilder = new UriBuilder(NavManager.Uri);
        uriBuilder.Query = uri.Query.ToString();
        uriBuilder.Fragment = null;
        uriBuilder.Query = null;

 OAuth2Response response = await DropboxOAuth2Helper.ProcessCodeFlowAsync(AuthCode, ApiKeyString, ApiSecretString, uriBuilder.Uri.AbsoluteUri, null, null);
}

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 20:23:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Net-Core-6-0-compatibility-Getting-OAuth2Exception-invalid-grant/m-p/588904#M27430</guid>
      <dc:creator>Tech Dev Oldsmar</dc:creator>
      <dc:date>2022-04-06T20:23:54Z</dc:date>
    </item>
  </channel>
</rss>

