<?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: C# ProcessCodeFlowAsync() invalid_grant error in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/C-ProcessCodeFlowAsync-invalid-grant-error/m-p/367719#M20806</link>
    <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;Alright, I think I just solved my own problem. Since I was testing ProcessCodeFlow() using try/catch, I couldn't use the same auth code twice in the same process. Eliminating that loop allowed me to change the access code.&lt;/P&gt;</description>
    <pubDate>Sat, 28 Sep 2019 02:38:10 GMT</pubDate>
    <dc:creator>AGreenTejada</dc:creator>
    <dc:date>2019-09-28T02:38:10Z</dc:date>
    <item>
      <title>C# ProcessCodeFlowAsync() invalid_grant error</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/C-ProcessCodeFlowAsync-invalid-grant-error/m-p/367718#M20805</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;I'm a year young to C# and brand new to the concept of API's. Been having sometime struggling with the OAuth process using the OAuth2Helper class.&lt;/P&gt;
&lt;P&gt;While I already have the AppKey and AppSecret from App Console, everytime I use the authorization code from GetAuthorizeURI (no redirectURI, I just copy/paste the authorization code into a WinForm), and push it into ProcessCodeFlowAsync(AuthCode, AppKey, AppSecret); I get an OAuth2Exception invalid_grant error. Anyone knows what's causing this?&lt;/P&gt;
&lt;P&gt;Here's the code I'm working on.&lt;/P&gt;
&lt;PRE&gt; public class Info {
 public static DropboxTeamClient teamClient = new DropboxTeamClient(AccessToken);
        public static DropboxClient admin = new DropboxClient(AccessToken);

        public static string AuthorizationCode { get; set; }
        public static async Task Authorize()
        {
            Uri redirect = new Uri("https://www.dropbox.com/oauth2/");
            var getURL = DropboxOAuth2Helper.GetAuthorizeUri(AppKey);
            System.Diagnostics.Process.Start(getURL.ToString());

            var token = new GetAuthToken();
            token.BringToFront();
            Application.Run(token);

            while (string.IsNullOrEmpty(AuthorizationCode))
            {
                MessageBox.Show("BEEP! NO PARAMETERS GIVEN", "Null Parameter");
                token = new GetAuthToken();
                Application.Run(token);
            }

            OAuth2Response AuthFlow;
            bool i = true;

            while (i)
            {
                try
                {
                    AuthFlow = await DropboxOAuth2Helper.ProcessCodeFlowAsync(AuthorizationCode, AppKey, AppSecret);
                    break;
                }
                catch (OAuth2Exception e)
                {
                    MessageBox.Show("BEEP! INCORRECT CODE GIVEN.", "Wrong Authorization Code");
                    token = new GetAuthToken();
                    Application.Run(token);
                }
            }

            AuthFlow = await DropboxOAuth2Helper.ProcessCodeFlowAsync(AuthorizationCode, AppKey, AppSecret, null,null) ;
            AccessToken = AuthFlow.AccessToken;
            MessageBox.Show(string.Format("The access token is {0}.", AccessToken), "SUCCESS!");

        }
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Sep 2019 05:36:56 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/C-ProcessCodeFlowAsync-invalid-grant-error/m-p/367718#M20805</guid>
      <dc:creator>AGreenTejada</dc:creator>
      <dc:date>2019-09-30T05:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: C# ProcessCodeFlowAsync() invalid_grant error</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/C-ProcessCodeFlowAsync-invalid-grant-error/m-p/367719#M20806</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;Alright, I think I just solved my own problem. Since I was testing ProcessCodeFlow() using try/catch, I couldn't use the same auth code twice in the same process. Eliminating that loop allowed me to change the access code.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 02:38:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/C-ProcessCodeFlowAsync-invalid-grant-error/m-p/367719#M20806</guid>
      <dc:creator>AGreenTejada</dc:creator>
      <dc:date>2019-09-28T02:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: C# ProcessCodeFlowAsync() invalid_grant error</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/C-ProcessCodeFlowAsync-invalid-grant-error/m-p/368087#M20812</link>
      <description>&lt;P&gt;Thanks for following up. I'm glad to hear you already sorted this out. Yes, the&amp;nbsp;Dropbox API OAuth 2 authorization&amp;nbsp;codes can only be used once each.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 15:31:55 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/C-ProcessCodeFlowAsync-invalid-grant-error/m-p/368087#M20812</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2019-09-30T15:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: C# ProcessCodeFlowAsync() invalid_grant error</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/C-ProcessCodeFlowAsync-invalid-grant-error/m-p/664836#M30114</link>
      <description>&lt;P&gt;Hey!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this is an old thread but this may help someone. I was using the API "DropboxOAuth2Helper.ProcessCodeFlowAsync" and got the same error -&amp;nbsp; "&lt;SPAN&gt;invalid_grant". The solution was to make sure that the redirectUri passed into "GetAuthorizeUri", matches the one passed into "ProcessCodeFlowAsync" if you're doing the whole flow. Then it worked just fine!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Have a nice day everyone!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 07:29:43 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/C-ProcessCodeFlowAsync-invalid-grant-error/m-p/664836#M30114</guid>
      <dc:creator>Huezzer</dc:creator>
      <dc:date>2023-03-03T07:29:43Z</dc:date>
    </item>
  </channel>
</rss>

