<?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: Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ? in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29192#M869</link>
    <description>&lt;P&gt;Hi Greg,&lt;/P&gt;

&lt;P&gt;Below is another issue:&lt;/P&gt;

&lt;P&gt;I created a Dropbox API app,  It includes APP key and APP secret now, and generated access token in my APP page.   Then I use lib 'dbox' in the browser-client.   Below is my JS:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var dboxclient = require('dbox');

var app = dboxclient.app({"app_key": "j4nrv1xhtjj3svq","app_secret":"&amp;lt;REDACTED&amp;gt;"});

var client = app.client("&amp;lt;REDACTED&amp;gt;");

module.exports = DBOX;

function DBOX() {

}

DBOX.prototype.getAccount = function() {
    client.account(function(status, reply){
        console.log(reply)
    });
}

DBOX.prototype.Metadata = function() {
    // available options...
    var options = {
        file_limit         : 10000,              // optional
        //hash               : ...,                // optional
        list               : true,               // optional
        include_deleted    : false,              // optional
        //rev                : 7,                  // optional
        credentials       : false,
        locale            : "en",               // optional
        root              : "sandbox"           // optional
    };

    client.metadata("started.pdf", options, function(status, reply) {
        console.log(reply);
    });
}

DBOX.prototype.Putfile = function() {
    client.put("hello.txt", "here is some text", function (status, reply) {
        console.log(reply);
    });
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I  call it in my another js like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var dbox = new DBOX();
        dbox.getAccount();
        //dbox.Putfile();
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It failed  with error message  in the browser console:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;POST https://api.dropbox.com/1/account/info request.js:117 Request.endmain.js:761 Request.endmain.js:345 (anonymous function)browser.js:19 drainQueue
localhost/:1 XMLHttpRequest cannot load https://api.dropbox.com/1/account/info. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:3000' is therefore not allowed access.
main.js:422 Uncaught TypeError: Cannot read property 'set-cookie' of undefinedmain.js:422 (anonymous function)events.js:77 EventEmitter.emitrequest.js:61 (anonymous function)events.js:74 EventEmitter.emitresponse.js:92 Response.handlerequest.js:73 xhr.onreadystatechange
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do you any Ideas?    &lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 15 May 2015 15:29:28 GMT</pubDate>
    <dc:creator>Li P.</dc:creator>
    <dc:date>2015-05-15T15:29:28Z</dc:date>
    <item>
      <title>Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29186#M863</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I  sent a request to salesforce , then get a JSON stream.   Now I want to save the stream object into a Dropbox file  by  sending Post request  in my code.   Does Dropbox have relative Post rest api ?  How can I do it?&lt;/P&gt;

&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:42:52 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29186#M863</guid>
      <dc:creator>Li P.</dc:creator>
      <dc:date>2019-05-29T09:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29187#M864</link>
      <description>&lt;P&gt;You can upload data to Dropbox using the /files_put endpoint on the Core API:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.dropbox.com/developers/core/docs#files_put" rel="nofollow noreferrer"&gt;https://www.dropbox.com/developers/core/docs#files_put&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;That endpoint accepts both PUT and POST. You can use the HTTP endpoints, such as the above, directly,  but we recommend using an official SDK if possible:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.dropbox.com/developers/core" rel="nofollow noreferrer"&gt;https://www.dropbox.com/developers/core&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Otherwise, there are some third party libraries listed here that may be helpful:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.dropbox.com/developers/core/sdks/other" rel="nofollow noreferrer"&gt;https://www.dropbox.com/developers/core/sdks/other&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 03:24:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29187#M864</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2015-05-15T03:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29188#M865</link>
      <description>&lt;P&gt;Hi Greg,&lt;BR /&gt;
Thanks very much for your prompt reply.   It is very helpful to me.&lt;BR /&gt;
I  tried to create an APP using 'Drop-In'  Saver type.   The APP just give me APP key,  but  no APP Secret.    Before I  post my stream data to the /file_put  endpoint,   I need to get authorized. right ? &lt;/P&gt;

&lt;P&gt;My APP is an browser client app.  And I found  the endpoint '/oauth2/token' (OAuth 2.0) maybe useful to me to get token (without user interactive), but where can I get  APP Secret?  Or  which endpoint is easy to get authorized without  user interactive? &lt;/P&gt;

&lt;P&gt;Best Regards.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 08:13:25 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29188#M865</guid>
      <dc:creator>Li P.</dc:creator>
      <dc:date>2015-05-15T08:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29189#M866</link>
      <description>&lt;P&gt;By the way,  After I got  access token,  How to use the token to post request to '/files_put' ?  It seems no parameter for access token to the endpoint.   Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 08:54:12 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29189#M866</guid>
      <dc:creator>Li P.</dc:creator>
      <dc:date>2015-05-15T08:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29190#M867</link>
      <description>&lt;P&gt;To use the Core API, you'll need to register a "Dropbox API app", not a "Drop-ins app":&lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.dropbox.com/developers/apps/create" rel="nofollow noreferrer"&gt;https://www.dropbox.com/developers/apps/create&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Drop-ins don't have app secrets, unlike Dropbox API apps.&lt;/P&gt;

&lt;P&gt;And yes, to use the Core API, you'll need to have the user authorize the app to access their account. Then, you can make API calls using the resulting access tokens. (If you only need to connect to your own account, you just need to do this once. You can also easily get an OAuth 2 access token for your own account as shown here: &lt;A href="https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/" rel="nofollow noreferrer"&gt;https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/&lt;/A&gt; )&lt;/P&gt;

&lt;P&gt;Note that getting an access token is a process that involves user intervention, but once you have it, you can store and re-use it for that account without further manual user intervention.&lt;/P&gt;

&lt;P&gt;We recommend using an SDK or library as I mentioned before, but if you can't for whatever reason, you can sign the calls using OAuth 1 or OAuth 2. We have blog posts for each:&lt;/P&gt;

&lt;P&gt;OAuth 1: &lt;A href="https://blogs.dropbox.com/developers/2012/07/using-oauth-1-0-with-the-plaintext-signature-method/" rel="nofollow noreferrer"&gt;https://blogs.dropbox.com/developers/2012/07/using-oauth-1-0-with-the-plaintext-signature-method/&lt;/A&gt;&lt;BR /&gt;
OAuth 2: &lt;A href="https://blogs.dropbox.com/developers/2013/07/using-oauth-2-0-with-the-core-api/" rel="nofollow noreferrer"&gt;https://blogs.dropbox.com/developers/2013/07/using-oauth-2-0-with-the-core-api/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 09:41:57 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29190#M867</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2015-05-15T09:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29191#M868</link>
      <description>&lt;P&gt;Hi Greg,&lt;BR /&gt;
Thanks for your patient !&lt;BR /&gt;&lt;BR /&gt;
I will use the lib "&lt;A href="https://github.com/sintaxi/dbox" rel="nofollow noreferrer"&gt;https://github.com/sintaxi/dbox&lt;/A&gt;",  and try to use my own account  (without user interactive).&lt;BR /&gt;
In future,  If user can provider dropbox account like 'username/password' , Is there any API to get  access token directly without  user interaction ?&lt;BR /&gt;&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 12:16:52 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29191#M868</guid>
      <dc:creator>Li P.</dc:creator>
      <dc:date>2015-05-15T12:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29192#M869</link>
      <description>&lt;P&gt;Hi Greg,&lt;/P&gt;

&lt;P&gt;Below is another issue:&lt;/P&gt;

&lt;P&gt;I created a Dropbox API app,  It includes APP key and APP secret now, and generated access token in my APP page.   Then I use lib 'dbox' in the browser-client.   Below is my JS:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var dboxclient = require('dbox');

var app = dboxclient.app({"app_key": "j4nrv1xhtjj3svq","app_secret":"&amp;lt;REDACTED&amp;gt;"});

var client = app.client("&amp;lt;REDACTED&amp;gt;");

module.exports = DBOX;

function DBOX() {

}

DBOX.prototype.getAccount = function() {
    client.account(function(status, reply){
        console.log(reply)
    });
}

DBOX.prototype.Metadata = function() {
    // available options...
    var options = {
        file_limit         : 10000,              // optional
        //hash               : ...,                // optional
        list               : true,               // optional
        include_deleted    : false,              // optional
        //rev                : 7,                  // optional
        credentials       : false,
        locale            : "en",               // optional
        root              : "sandbox"           // optional
    };

    client.metadata("started.pdf", options, function(status, reply) {
        console.log(reply);
    });
}

DBOX.prototype.Putfile = function() {
    client.put("hello.txt", "here is some text", function (status, reply) {
        console.log(reply);
    });
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I  call it in my another js like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var dbox = new DBOX();
        dbox.getAccount();
        //dbox.Putfile();
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It failed  with error message  in the browser console:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;POST https://api.dropbox.com/1/account/info request.js:117 Request.endmain.js:761 Request.endmain.js:345 (anonymous function)browser.js:19 drainQueue
localhost/:1 XMLHttpRequest cannot load https://api.dropbox.com/1/account/info. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:3000' is therefore not allowed access.
main.js:422 Uncaught TypeError: Cannot read property 'set-cookie' of undefinedmain.js:422 (anonymous function)events.js:77 EventEmitter.emitrequest.js:61 (anonymous function)events.js:74 EventEmitter.emitresponse.js:92 Response.handlerequest.js:73 xhr.onreadystatechange
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do you any Ideas?    &lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 15:29:28 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29192#M869</guid>
      <dc:creator>Li P.</dc:creator>
      <dc:date>2015-05-15T15:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29193#M870</link>
      <description>&lt;P&gt;That's a security feature of CORS. I'm not familiar with the dbox library you're using, but you need to make sure you don't use credentials (i.e., the withCredentials XHR field, for example, to set cookies) when making these API calls.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 21:34:48 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29193#M870</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2015-05-15T21:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29194#M871</link>
      <description>&lt;P&gt;Greg, thanks!&lt;BR /&gt;
I don't familiar with dbox, and don't know how to set config before  send request.  So I will use the '/files_put' rest.    Now The question is how I  can attach the access token (generated in my app page) when sending post to '/files_put' ?  It seems '/files_put' has not this parameter in Core API document.&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 22:10:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29194#M871</guid>
      <dc:creator>Li P.</dc:creator>
      <dc:date>2015-05-15T22:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29195#M872</link>
      <description>&lt;P&gt;Just set the &lt;CODE&gt;Authorization&lt;/CODE&gt; header to &lt;CODE&gt;Bearer &amp;lt;token&amp;gt;&lt;/CODE&gt;. The documentation doesn't mention this, because it's just how OAuth 2 works.&lt;/P&gt;

&lt;P&gt;BTW, I redacted the access token in your post, but just in case someone else saw it, you should make sure to disable it. Unlinking your app from the &lt;A href="https://www.dropbox.com/account#security" rel="nofollow noreferrer"&gt;account security&lt;/A&gt; tab and then relinking (getting a new token) should do the trick.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 22:33:57 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29195#M872</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2015-05-15T22:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can I  save a JSON stream object to Dropbox file   with Dropbox Post Rest API ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29196#M873</link>
      <description>&lt;P&gt;Thanks, Steve.&lt;BR /&gt;
I will try it when I get chance.  Both of you have a nice day.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 22:39:13 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-I-save-a-JSON-stream-object-to-Dropbox-file-with-Dropbox/m-p/29196#M873</guid>
      <dc:creator>Li P.</dc:creator>
      <dc:date>2015-05-15T22:39:13Z</dc:date>
    </item>
  </channel>
</rss>

