<?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: Token refreshing C# in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620744#M28624</link>
    <description>&lt;P&gt;As Здравко said, as long as you provide the required credentials, the Dropbox .NET SDK will handle the refresh process for you automatically. I see you've already mentioned the example of getting and using a refresh token in &lt;A href="https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Examples/OauthBasic/Program.cs" rel="noopener noreferrer" target="_blank"&gt;the OauthBasic example&lt;/A&gt; (non-PKCE, meant for server-side apps); there's also &lt;A href="https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Examples/OAuthPKCE/Program.cs" rel="noopener noreferrer" target="_blank"&gt;the OAuthPKCE example&lt;/A&gt; (PKCE, meant for client-side apps).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you elaborate on what you mean when you say it "doesn't work" for you? What have you done so far, and what specifically isn't working and how?&lt;/P&gt;</description>
    <pubDate>Tue, 06 Sep 2022 13:53:13 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2022-09-06T13:53:13Z</dc:date>
    <item>
      <title>Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620540#M28598</link>
      <description>&lt;P&gt;I'm building an app in .net and accessing the app's folder for resources. So far everything is going smoothly, but i have no idea how to refresh the token in my app. I tried using the example code from OauthBasic from github, but i have a vague understanding of it and doesn't work for me. Would appreciate some help and guidance with it as i have no idea how to set it up. Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 09:49:16 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620540#M28598</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-06T09:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620602#M28606</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1571151"&gt;@Melisek&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;... So far everything is going smoothly, but i have no idea how to refresh the token in my app. ...&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1571151"&gt;@Melisek&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;As far as you have set/constructed your Dropbox client object properly (as shown in all examples - including basic), you wont need to refresh any token explicitly. The client object does take care and refresh whenever need without your explicit action/instruction.&amp;nbsp;&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt; That's it. Do you provide the refresh token every time new client object brings up or... not exactly? 🧐&lt;/P&gt;&lt;P&gt;Hope this gives direction.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 22:32:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620602#M28606</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-09-05T22:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620744#M28624</link>
      <description>&lt;P&gt;As Здравко said, as long as you provide the required credentials, the Dropbox .NET SDK will handle the refresh process for you automatically. I see you've already mentioned the example of getting and using a refresh token in &lt;A href="https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Examples/OauthBasic/Program.cs" rel="noopener noreferrer" target="_blank"&gt;the OauthBasic example&lt;/A&gt; (non-PKCE, meant for server-side apps); there's also &lt;A href="https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Examples/OAuthPKCE/Program.cs" rel="noopener noreferrer" target="_blank"&gt;the OAuthPKCE example&lt;/A&gt; (PKCE, meant for client-side apps).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you elaborate on what you mean when you say it "doesn't work" for you? What have you done so far, and what specifically isn't working and how?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 13:53:13 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620744#M28624</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-09-06T13:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620772#M28640</link>
      <description>&lt;P&gt;When i run my app, the Run task is probably stopping at some point as when i try to acces dropbox files it throws out a NullReferenceException of the DropboxClient and i have no clue on how to get the refresh token. Also the ApiKey and ApiSecret are replaced in my code.&lt;/P&gt;&lt;P&gt;Here is what i have inside my app so far:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;public partial class RWindow : Form
    {
        //Dropbox stuff
        private const string ApiKey = "";

        private const string ApiSecret = "";

        private const string LoopbackHost = "http://127.0.0.1:52475/";

        // URL to receive OAuth 2 redirect from Dropbox server.
        // You also need to register this redirect URL on https://www.dropbox.com/developers/apps.
        private static readonly Uri RedirectUri = new Uri(LoopbackHost + "authorize");

        // URL to receive access token from JS.
        private static readonly Uri JSRedirectUri = new Uri(LoopbackHost + "token");

        static DropboxClient dbx;
        private List&amp;lt;string&amp;gt; fileNames = new List&amp;lt;string&amp;gt;();
        private string folder;


        public RWindow()
        {
            InitializeComponent();
            var task = Task.Run((Func&amp;lt;Task&amp;gt;)Run);
            task.Wait();
        }

        static async Task Run()
        {
            DropboxCertHelper.InitializeCertPinning();

            string[] scopeList = new string[3] { "files.metadata.read", "files.content.read", "account_info.read" };
            var uid = await AcquireAccessToken(scopeList, IncludeGrantedScopes.None);
            if (string.IsNullOrEmpty(uid))
            {
                return;
            }

            var httpClient = new HttpClient(new WebRequestHandler { ReadWriteTimeout = 10 * 1000 })
            {
                Timeout = TimeSpan.FromMinutes(20)
            };

            try
            {
                var config = new DropboxClientConfig("SimplePKCEOAuthApp")
                {
                    HttpClient = httpClient
                };

                dbx = new DropboxClient(Settings.Default.RefreshToken, ApiKey, config);

                await dbx.RefreshAccessToken(scopeList);
                await AcquireAccessToken(scopeList, IncludeGrantedScopes.User);

                dbx = new DropboxClient(Settings.Default.AccessToken, Settings.Default.RefreshToken, ApiKey, ApiSecret, config);
            }
            catch (HttpException e)
            {
                Debug.WriteLine("Exception reported from RPC layer");
                Debug.WriteLine("    Status code: {0}", e.StatusCode);
                Debug.WriteLine("    Message    : {0}", e.Message);
                if (e.RequestUri != null)
                {
                    Debug.WriteLine("    Request uri: {0}", e.RequestUri);
                }
            }
        }

        private static async Task HandleOAuth2Redirect(HttpListener http)
        {
            var context = await http.GetContextAsync();

            // We only care about request to RedirectUri endpoint.
            while (context.Request.Url.AbsolutePath != RedirectUri.AbsolutePath)
            {
                context = await http.GetContextAsync();
            }

            context.Response.ContentType = "text/html";

            // Respond with a page which runs JS and sends URL fragment as query string
            // to TokenRedirectUri.
            using (var file = File.OpenRead("index.html"))
            {
                file.CopyTo(context.Response.OutputStream);
            }

            context.Response.OutputStream.Close();
        }

        private static async Task&amp;lt;Uri&amp;gt; HandleJSRedirect(HttpListener http)
        {
            var context = await http.GetContextAsync();

            // We only care about request to TokenRedirectUri endpoint.
            while (context.Request.Url.AbsolutePath != JSRedirectUri.AbsolutePath)
            {
                context = await http.GetContextAsync();
            }

            var redirectUri = new Uri(context.Request.QueryString["url_with_fragment"]);

            return redirectUri;
        }

        private static async Task&amp;lt;string&amp;gt; AcquireAccessToken(string[] scopeList, IncludeGrantedScopes includeGrantedScopes)
        {
            Settings.Default.Reset();

            var accessToken = Settings.Default.AccessToken;
            var refreshToken = Settings.Default.RefreshToken;

            if (string.IsNullOrEmpty(accessToken))
            {
                try
                {
                    Debug.WriteLine("Waiting for credentials.");
                    var state = Guid.NewGuid().ToString("N");
                    var authorizeUri = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Code, ApiKey, RedirectUri, state: state, tokenAccessType: TokenAccessType.Offline, scopeList: scopeList, includeGrantedScopes: includeGrantedScopes);
                    var http = new HttpListener();
                    http.Prefixes.Add(LoopbackHost);

                    http.Start();

                    System.Diagnostics.Process.Start(authorizeUri.ToString());

                    // Handle OAuth redirect and send URL fragment to local server using JS.
                    await HandleOAuth2Redirect(http);

                    // Handle redirect from JS and process OAuth response.
                    var redirectUri = await HandleJSRedirect(http);

                    var tokenResult = await DropboxOAuth2Helper.ProcessCodeFlowAsync(redirectUri, ApiKey, ApiSecret, RedirectUri.ToString(), state);
                    accessToken = tokenResult.AccessToken;
                    refreshToken = tokenResult.RefreshToken;
                    var uid = tokenResult.Uid;
                    Debug.WriteLine("Uid: {0}", uid);
                    Debug.WriteLine("AccessToken: {0}", accessToken);
                    if (tokenResult.RefreshToken != null)
                    {
                        Debug.WriteLine("RefreshToken: {0}", refreshToken);
                        Settings.Default.RefreshToken = refreshToken;
                    }
                    if (tokenResult.ExpiresAt != null)
                    {
                        Debug.WriteLine("ExpiresAt: {0}", tokenResult.ExpiresAt);
                    }
                    if (tokenResult.ScopeList != null)
                    {
                        Debug.WriteLine("Scopes: {0}", String.Join(" ", tokenResult.ScopeList));
                    }
                    Settings.Default.AccessToken = accessToken;
                    Settings.Default.Uid = uid;
                    Settings.Default.Save();
                    http.Stop();
                    return uid;
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Error: {0}", e.Message);
                    return null;
                }
            }

            return null;
        }
//Rest of my code that handles requesting and downloading files stored in the application. Works properly when using the generated short-lived token in app console.
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 06 Sep 2022 16:28:53 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620772#M28640</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-06T16:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620779#M28642</link>
      <description>&lt;P&gt;Also found this error&lt;/P&gt;&lt;P&gt;An error occurred trying to start process '&lt;A href="https://www.dropbox.com/oauth2/authorize?response_type=code&amp;amp;client_id=XXXXXXXXXXXXXXX&amp;amp;redirect_uri=http%3A%2F%2F127.0.0.1%3A52475%2Fauthorize&amp;amp;state=a6a4da2fe0f44dfe91c14f6a0917c8ac&amp;amp;token_access_type=offline&amp;amp;scope=files.metadata.read" target="_blank"&gt;https://www.dropbox.com/oauth2/authorize?response_type=code&amp;amp;client_id=XXXXXXXXXXXXXXX&amp;amp;redirect_uri=http%3A%2F%2F127.0.0.1%3A52475%2Fauthorize&amp;amp;state=a6a4da2fe0f44dfe91c14f6a0917c8ac&amp;amp;token_access_type=offline&amp;amp;scope=files.metadata.read&lt;/A&gt; files.content.read account_info.read' with working directory 'C:\Programming\C#\MelisekGameManager\MelisekGameManager\bin\Debug\net6.0-windows'. Can't find specified file.: Error: {0}&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 16:53:44 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620779#M28642</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-06T16:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620840#M28646</link>
      <description>&lt;P&gt;To clarify, are you seeing the NullReferenceException in addition to the "Can't find specified file" error, or are you no longer getting a NullReferenceException?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either way, is that the entirety of the error/output you're getting? Please be sure to share the whole error/output and whatever details you can if not, as it's not quite clear here. For example, if your IDE shows which line something is failing on, please show that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, it sounds like that "Can't find specified file" error is occurring when attempting to launch the authorization URL in the system browser, on the System.Diagnostics.Process.Start line, but is the authorization page actually launching in the browser or not? It's unclear why that would fail but it may depend on your particular environment. For example, it sounds similar to &lt;A href="https://stackoverflow.com/questions/21835891/process-starturl-fails" target="_blank"&gt;this issue&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 20:11:39 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620840#M28646</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-09-06T20:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620849#M28648</link>
      <description>&lt;P&gt;That's the entirety of the error output unless this is also paired with the error output:&lt;/P&gt;&lt;P&gt;Exception thrown: „System.ComponentModel.Win32Exception” in System.Diagnostics.Process.dll&lt;/P&gt;&lt;P&gt;The nullreference shows because the dropbox client isn't getting assigned in the Run tast as it doesn't reach this point of the task. The authorization page doesn't open.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 20:39:13 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620849#M28648</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-06T20:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620878#M28649</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1571151"&gt;@Melisek&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Are you certain that Windows machine, used as a DUT, has properly set default web browser? 🧐 Try set it anew or change to some other. If no luck yet, test again with a bit changed 'authorizeUri'. Add to following line:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1571151"&gt;@Melisek&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;...&lt;/P&gt;&lt;PRE&gt;...
                    System.Diagnostics.Process.Start(authorizeUri.ToString());
&lt;BR /&gt;...&lt;/PRE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;...a real browser name to avoid relying on system settings (possibly broken). It can come up something like:&lt;/P&gt;&lt;PRE&gt;System.Diagnostics.Process.Start("firefox", authorizeUri.ToString());&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Of course, other web browser can be used (on your opinion) too!&lt;/P&gt;&lt;P&gt;Let see the result...&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@9AD39CA637682E9616FBE31CDAF1B6C4/emoticons/1f914.png" alt=":thinking_face:" title=":thinking_face:" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 22:43:07 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620878#M28649</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-09-06T22:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620995#M28660</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1571151"&gt;@Melisek&lt;/a&gt; Thanks for following up. As Здравко said, please make sure the environment has a default web browser set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, it looks like you may be using Windows Forms, so please refer to &lt;A href="https://stackoverflow.com/questions/21835891/process-starturl-fails" target="_blank"&gt;this post&lt;/A&gt; for options, as it appears you may need to use something other than System.Diagnostics.Process.Start in that environment.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 14:17:34 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/620995#M28660</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-09-07T14:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621008#M28662</link>
      <description>&lt;P&gt;Yes i'm using WPF.&lt;/P&gt;&lt;P&gt;After giving the full path to the browser executable, it opens in the browser with the authorization site and for some reason opens two tabs passing into the URLS:&amp;nbsp;&lt;A href="http://files.content.read" target="_blank"&gt;http://files.content.read&lt;/A&gt;&amp;nbsp;and&amp;nbsp;&lt;A href="http://account_info.read" target="_blank"&gt;http://account_info.read&lt;/A&gt;. But after allowing the app in the authorization site it throws this exception:&lt;/P&gt;&lt;P&gt;Exception thrown: „System.IO.FileNotFoundException” in System.Private.CoreLib.dll&lt;BR /&gt;Exception thrown: „System.IO.FileNotFoundException” in System.Private.CoreLib.dll&lt;BR /&gt;Could not find file 'C:\Programming\C#\MelisekGameManager\MelisekGameManager\bin\Debug\net6.0-windows\index.html'.: Error: {0}&lt;/P&gt;&lt;P&gt;I think it's probably because i used the OauthBasic instead of OauthPKCE.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 15:06:33 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621008#M28662</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-07T15:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621016#M28667</link>
      <description>&lt;P&gt;Seems improper argument quoting. Space chars are used as a scopes separator, but the same chars are arguments separators too. Try following version:&lt;/P&gt;&lt;PRE&gt;System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(authorizeUri.ToString()) {UseShellExecute = true});&lt;/PRE&gt;&lt;P&gt;I believe, now it's gonna work. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 15:21:50 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621016#M28667</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-09-07T15:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621017#M28668</link>
      <description>&lt;P&gt;Replaced it and it's still the same (i added the path to the browser). Checked it on another browser just in case, and it persists on there too.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 15:35:38 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621017#M28668</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-07T15:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621022#M28669</link>
      <description>&lt;P&gt;If you mean the missing file, are you certain 'C:\Programming\C#\MelisekGameManager\MelisekGameManager\bin\Debug\net6.0-windows\index.html' exists?&amp;nbsp;&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@9AD39CA637682E9616FBE31CDAF1B6C4/emoticons/1f914.png" alt=":thinking_face:" title=":thinking_face:" /&gt; Take a look.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 15:41:09 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621022#M28669</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-09-07T15:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621023#M28670</link>
      <description>&lt;P&gt;it doesn't exist there.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 15:48:27 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621023#M28670</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-07T15:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621063#M28678</link>
      <description>&lt;P&gt;Ok so i created the index.html in the project and included it into the build folder, and as of now opening still opens that 2 additional tabs for no reason, after completing oauth it opens the site, but the app window doesn't open.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="obraz_2022-09-07_200720675.png" style="width: 800px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/31487i166F9BE944C3E9E3/image-size/large?v=v2&amp;amp;px=999" role="button" title="obraz_2022-09-07_200720675.png" alt="obraz_2022-09-07_200720675.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I set up some breakpoints to test where the code stops, and it gets stuck on the AcquireAccessToken Task.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 18:08:49 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621063#M28678</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-07T18:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621067#M28679</link>
      <description>&lt;P&gt;Realized there was and index.html in the github repo so copied the code from it and now i get this exception on task.Wait:&lt;/P&gt;&lt;P&gt;System.AggregateException: „One or more errors occurred. (Method not found: 'Void System.Net.Http.HttpClientHandler.CheckDisposedOrStarted()'.)”&lt;/P&gt;&lt;P&gt;InternalException&lt;/P&gt;&lt;P&gt;MissingMethodException: Method not found: 'Void System.Net.Http.HttpClientHandler.CheckDisposedOrStarted()'.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 18:21:15 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621067#M28679</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-07T18:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621086#M28682</link>
      <description>&lt;P&gt;After some tinkering around i finally managed to get everything working! I removed the HttpClient and some lines that were not needed/unwanted and the app is running without any problems. I got the refresh token from the returned message and everything works fine without needing to authorize in the browser. Thank you for your time helping me.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 19:48:59 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621086#M28682</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-07T19:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621107#M28686</link>
      <description>&lt;P&gt;Actually i have one (probably) last question. Why does it throw out a AuthException: missing_scope/.. exception when downloading a file using dbx.Files.DownloadAsync. I'm refreshing for a new token with file.content.read permission as shown below, yet i can't download it. The result of RefreshAccessToken returns true.&lt;/P&gt;&lt;P&gt;I can also read file info like its name.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;static async Task Run()
        {
            DropboxCertHelper.InitializeCertPinning();

            Settings.Default.RefreshToken = refreshToken;

            string[] scopeList = new string[3] { "files.metadata.read", "files.content.read", "account_info.read" };

            var config = new DropboxClientConfig("SimplePKCEOAuthApp");

            dbx = new DropboxClient(Settings.Default.AccessToken, Settings.Default.RefreshToken, ApiKey, ApiSecret, config);
            Debug.WriteLine(await dbx.RefreshAccessToken(scopeList));
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 21:02:11 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621107#M28686</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-07T21:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621110#M28687</link>
      <description>&lt;P&gt;A 'missing_scope' error indicates that while the app is permitted to use that scope, the particular access token you're using to make the API call does not have that scope granted. Also, be aware that just adding a scope to your app via the &lt;A href="https://www.dropbox.com/developers/apps" target="_blank" rel="noopener noreferrer"&gt;App Console&lt;/A&gt; does not retroactively grant that scope to existing access tokens.&lt;BR /&gt;&lt;BR /&gt;That being the case, to make any API calls that require that scope, you'll need to get a new access token/refresh token with that scope. That is, you'll need to process the app authorization flow again, starting from&amp;nbsp;GetAuthorizeUri, with the necessary scope specified. Just calling RefreshAccessToken with the added scope won't grant that scope, since you can't automatically get an access token with a scope not actually authorized by the user when creating that refresh token originally.&lt;BR /&gt;&lt;BR /&gt;Refer to the &lt;A href="https://developers.dropbox.com/oauth-guide" target="_blank" rel="noopener noreferrer"&gt;OAuth Guide&lt;/A&gt; and &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#authorization" target="_blank" rel="noopener noreferrer"&gt;authorization documentation&lt;/A&gt; for more information.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 21:12:40 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621110#M28687</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-09-07T21:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: Token refreshing C#</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621190#M28692</link>
      <description>&lt;P&gt;Now i found out why two additional tabs were opening.&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.dropbox.com/oauth2/authorize?response_type=code&amp;amp;client_id=XXXXXXXX&amp;amp;redirect_uri=http%3A%2F%2F127.0.0.1%3A52475%2Fauthorize&amp;amp;state=XXXXX&amp;amp;token_access_type=offline&amp;amp;scope=files.metadata.read" target="_blank"&gt;https://www.dropbox.com/oauth2/authorize?response_type=code&amp;amp;client_id=XXXXXXXX&amp;amp;redirect_uri=http%3A%2F%2F127.0.0.1%3A52475%2Fauthorize&amp;amp;state=XXXXX&amp;amp;token_access_type=offline&amp;amp;scope=files.metadata.read&lt;/A&gt; files.content.read account_info.read&amp;amp;code_challenge_method=S256&amp;amp;code_challenge=XXXX&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The OauthFlow.GetauthorizeUri returned the url with spaces instead of + in the scopes.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 06:32:52 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Token-refreshing-C/m-p/621190#M28692</guid>
      <dc:creator>Melisek</dc:creator>
      <dc:date>2022-09-08T06:32:52Z</dc:date>
    </item>
  </channel>
</rss>

