<?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: Python sdk error DropboxAuth2Flow in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-sdk-error-DropboxAuth2Flow/m-p/257378#M14923</link>
    <description>&lt;P&gt;It looks like you're referring to the example code in &lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.oauth.DropboxOAuth2Flow" target="_self"&gt;the&amp;nbsp;DropboxOAuth2Flow documentation&lt;/A&gt;. That example code isn't a complete sample, so it won't work on its own. For instance, it&amp;nbsp;doesn't include definitions for `redirect_to` or `http_status`. It's just meant as an outline of how you would implement this in a web app using a web framework.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, to clarify, are you building a web app using a web framework?&amp;nbsp;You don't need to use Flask in particular, but the&amp;nbsp;expectation&amp;nbsp;for that sample is that you would be using some framework that provides the functionality for `redirect_to` or `http_status` (or that you would build your own). In that case,&amp;nbsp;the line `redirect_to(authorize_url)` would send the user to the Dropbox OAuth app authorization page.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You said that you're "trying to build a simple python script that will let user authenticate using browser", so it sounds like you may not be building a web app, but rather a local app. In that case, you would still need to have the use the browser to have the user authorize the app, but you're not in a&amp;nbsp;context where you can just redirect them there. In that case, &lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.oauth.DropboxOAuth2FlowNoRedirect" target="_self"&gt;DropboxOAuth2FlowNoRedirect&lt;/A&gt;&amp;nbsp;may make more sense for your use case. There's a small sample in the documentation for that too that may be helpful.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Dec 2017 16:54:17 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2017-12-20T16:54:17Z</dc:date>
    <item>
      <title>Python sdk error DropboxAuth2Flow</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-sdk-error-DropboxAuth2Flow/m-p/257284#M14917</link>
      <description>&lt;P&gt;I am using python sdk to list and download files but getting stuck at authetication. Using this code to authenticate user to allow access.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;from &lt;/SPAN&gt;dropbox &lt;SPAN&gt;import &lt;/SPAN&gt;DropboxOAuth2Flow&lt;SPAN&gt;, &lt;/SPAN&gt;oauth&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;http_status&lt;BR /&gt;&lt;BR /&gt;APP_KEY = &lt;SPAN&gt;'mykey'&lt;BR /&gt;&lt;/SPAN&gt;APP_SECRET = &lt;SPAN&gt;'mysecretkey'&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;get_dropbox_auth_flow&lt;/SPAN&gt;(web_app_session):&lt;BR /&gt;    redirect_uri = &lt;SPAN&gt;"https://my-web-server.org/dropbox-auth-finish"&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;return &lt;/SPAN&gt;DropboxOAuth2Flow(&lt;BR /&gt;        APP_KEY&lt;SPAN&gt;, &lt;/SPAN&gt;APP_SECRET&lt;SPAN&gt;, &lt;/SPAN&gt;redirect_uri&lt;SPAN&gt;, &lt;/SPAN&gt;web_app_session&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;        &lt;SPAN&gt;"dropbox-auth-csrf-token"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# URL handler for /dropbox-auth-start&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;dropbox_auth_start&lt;/SPAN&gt;(web_app_session&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;request&lt;/SPAN&gt;):&lt;BR /&gt;    authorize_url = get_dropbox_auth_flow(web_app_session).start()&lt;BR /&gt;    redirect_to(authorize_url)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# URL handler for /dropbox-auth-finish&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;dropbox_auth_finish&lt;/SPAN&gt;(web_app_session&lt;SPAN&gt;, &lt;/SPAN&gt;request):&lt;BR /&gt;    &lt;SPAN&gt;try&lt;/SPAN&gt;:&lt;BR /&gt;        &lt;SPAN&gt;oauth_result &lt;/SPAN&gt;= \&lt;BR /&gt;            get_dropbox_auth_flow(web_app_session).finish(&lt;BR /&gt;                request.query_params)&lt;BR /&gt;    &lt;SPAN&gt;except &lt;/SPAN&gt;oauth.BadRequestException &lt;SPAN&gt;as &lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;:&lt;BR /&gt;        http_status(&lt;SPAN&gt;400&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;except &lt;/SPAN&gt;oauth.BadStateException &lt;SPAN&gt;as &lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;:&lt;BR /&gt;        &lt;SPAN&gt;# Start the auth flow again.&lt;BR /&gt;&lt;/SPAN&gt;        redirect_to(&lt;SPAN&gt;"/dropbox-auth-start"&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;except &lt;/SPAN&gt;oauth.CsrfException &lt;SPAN&gt;as &lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;:&lt;BR /&gt;        http_status(&lt;SPAN&gt;403&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;except &lt;/SPAN&gt;oauth.NotApprovedException &lt;SPAN&gt;as &lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;:&lt;BR /&gt;        flash(&lt;SPAN&gt;'Not approved?  Why not?'&lt;/SPAN&gt;)&lt;BR /&gt;        &lt;SPAN&gt;return &lt;/SPAN&gt;redirect_to(&lt;SPAN&gt;"/home"&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;except &lt;/SPAN&gt;oauth.ProviderException &lt;SPAN&gt;as &lt;/SPAN&gt;e:&lt;BR /&gt;        logger.log(&lt;SPAN&gt;"Auth error: %s" &lt;/SPAN&gt;% (e&lt;SPAN&gt;,&lt;/SPAN&gt;))&lt;BR /&gt;        http_status(&lt;SPAN&gt;403&lt;/SPAN&gt;)&lt;/PRE&gt;
&lt;P&gt;Following:&amp;nbsp;&lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#module-dropbox.oauth" target="_blank"&gt;https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#module-dropbox.oauth&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Getting "Unresolved reference 'redirect_to'" same with logger and flash. I also get&amp;nbsp;'http_status' is not callable. Do I need &lt;EM&gt;Flask&amp;nbsp;&lt;/EM&gt;to run this code? I am trying to build a simple python script that will let user authenticate using browser.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:16:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-sdk-error-DropboxAuth2Flow/m-p/257284#M14917</guid>
      <dc:creator>pyraxic</dc:creator>
      <dc:date>2019-05-29T09:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Python sdk error DropboxAuth2Flow</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-sdk-error-DropboxAuth2Flow/m-p/257286#M14918</link>
      <description>&lt;P&gt;Okay, so I tried importing all the modules required to run this script as below and there are no errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;from &lt;/SPAN&gt;dropbox &lt;SPAN&gt;import &lt;/SPAN&gt;DropboxOAuth2Flow&lt;SPAN&gt;, &lt;/SPAN&gt;oauth&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;http_status&lt;BR /&gt;&lt;SPAN&gt;from &lt;/SPAN&gt;flask &lt;SPAN&gt;import &lt;/SPAN&gt;flash&lt;BR /&gt;&lt;BR /&gt;APP_KEY = &lt;SPAN&gt;'mykey'&lt;BR /&gt;&lt;/SPAN&gt;APP_SECRET = &lt;SPAN&gt;'mysecretkey'&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;get_dropbox_auth_flow&lt;/SPAN&gt;(web_app_session):&lt;BR /&gt;    redirect_uri = &lt;SPAN&gt;"https://my-web-server.org/dropbox-auth-finish"&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;return &lt;/SPAN&gt;DropboxOAuth2Flow(&lt;BR /&gt;        APP_KEY&lt;SPAN&gt;, &lt;/SPAN&gt;APP_SECRET&lt;SPAN&gt;, &lt;/SPAN&gt;redirect_uri&lt;SPAN&gt;, &lt;/SPAN&gt;web_app_session&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;        &lt;SPAN&gt;"dropbox-auth-csrf-token"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# URL handler for /dropbox-auth-start&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;dropbox_auth_start&lt;/SPAN&gt;(web_app_session&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;request&lt;/SPAN&gt;):&lt;BR /&gt;    authorize_url = get_dropbox_auth_flow(web_app_session).start()&lt;BR /&gt;    redirect_to(authorize_url)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# URL handler for /dropbox-auth-finish&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;dropbox_auth_finish&lt;/SPAN&gt;(web_app_session&lt;SPAN&gt;, &lt;/SPAN&gt;request):&lt;BR /&gt;    &lt;SPAN&gt;try&lt;/SPAN&gt;:&lt;BR /&gt;        &lt;SPAN&gt;oauth_result &lt;/SPAN&gt;= \&lt;BR /&gt;            get_dropbox_auth_flow(web_app_session).finish(&lt;BR /&gt;                request.query_params)&lt;BR /&gt;    &lt;SPAN&gt;except &lt;/SPAN&gt;oauth.BadRequestException &lt;SPAN&gt;as &lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;:&lt;BR /&gt;        http_status(&lt;SPAN&gt;400&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;except &lt;/SPAN&gt;oauth.BadStateException &lt;SPAN&gt;as &lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;:&lt;BR /&gt;        &lt;SPAN&gt;# Start the auth flow again.&lt;BR /&gt;&lt;/SPAN&gt;        redirect_to(&lt;SPAN&gt;"/dropbox-auth-start"&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;except &lt;/SPAN&gt;oauth.CsrfException &lt;SPAN&gt;as &lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;:&lt;BR /&gt;        http_status(&lt;SPAN&gt;403&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;except &lt;/SPAN&gt;oauth.NotApprovedException &lt;SPAN&gt;as &lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;:&lt;BR /&gt;        flash(&lt;SPAN&gt;'Not approved?  Why not?'&lt;/SPAN&gt;)&lt;BR /&gt;        &lt;SPAN&gt;return &lt;/SPAN&gt;redirect_to(&lt;SPAN&gt;"/home"&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;except &lt;/SPAN&gt;oauth.ProviderException &lt;SPAN&gt;as &lt;/SPAN&gt;e:&lt;BR /&gt;        logger.log(&lt;SPAN&gt;"Auth error: %s" &lt;/SPAN&gt;% (e&lt;SPAN&gt;,&lt;/SPAN&gt;))&lt;BR /&gt;        http_status(&lt;SPAN&gt;403&lt;/SPAN&gt;)&lt;/PRE&gt;
&lt;P&gt;But it doesn't seem to open up the browser for authentication from the user. Am I missing something?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2017 23:51:57 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-sdk-error-DropboxAuth2Flow/m-p/257286#M14918</guid>
      <dc:creator>pyraxic</dc:creator>
      <dc:date>2017-12-19T23:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python sdk error DropboxAuth2Flow</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-sdk-error-DropboxAuth2Flow/m-p/257378#M14923</link>
      <description>&lt;P&gt;It looks like you're referring to the example code in &lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.oauth.DropboxOAuth2Flow" target="_self"&gt;the&amp;nbsp;DropboxOAuth2Flow documentation&lt;/A&gt;. That example code isn't a complete sample, so it won't work on its own. For instance, it&amp;nbsp;doesn't include definitions for `redirect_to` or `http_status`. It's just meant as an outline of how you would implement this in a web app using a web framework.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, to clarify, are you building a web app using a web framework?&amp;nbsp;You don't need to use Flask in particular, but the&amp;nbsp;expectation&amp;nbsp;for that sample is that you would be using some framework that provides the functionality for `redirect_to` or `http_status` (or that you would build your own). In that case,&amp;nbsp;the line `redirect_to(authorize_url)` would send the user to the Dropbox OAuth app authorization page.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You said that you're "trying to build a simple python script that will let user authenticate using browser", so it sounds like you may not be building a web app, but rather a local app. In that case, you would still need to have the use the browser to have the user authorize the app, but you're not in a&amp;nbsp;context where you can just redirect them there. In that case, &lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.oauth.DropboxOAuth2FlowNoRedirect" target="_self"&gt;DropboxOAuth2FlowNoRedirect&lt;/A&gt;&amp;nbsp;may make more sense for your use case. There's a small sample in the documentation for that too that may be helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 16:54:17 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-sdk-error-DropboxAuth2Flow/m-p/257378#M14923</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-12-20T16:54:17Z</dc:date>
    </item>
  </channel>
</rss>

