<?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 Salesforce To dropbox file upload in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Salesforce-To-dropbox-file-upload/m-p/261185#M15231</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to upload a file from salesforce to Dropbox.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a class&amp;nbsp;in salesforce as per suggestions from the internet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public class dropBoxApi{&lt;BR /&gt;Public String code ;&lt;BR /&gt;Public String accesstoken;&lt;BR /&gt;public String fileBody{get;set;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;public dropBoxApi()&lt;BR /&gt;{&lt;BR /&gt;code = ApexPages.currentPage().getParameters().get('code') ;&lt;BR /&gt;System.debug('Code='+code);&lt;BR /&gt;if(code != '' &amp;amp;&amp;amp; code != null)&lt;BR /&gt;{&lt;BR /&gt;AccessToken() ;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;public PageReference DropAuth()&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;system.debug('UPLOAD'+accessToken );&lt;BR /&gt;//Authenticating&lt;BR /&gt;PageReference pg = new PageReference('&lt;A href="https://www.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id={clientId}&amp;amp;redirect_uri=https://c.na46.visual.force.com/apex/DropBoxPage&amp;amp;state=Mytesting" target="_blank"&gt;https://www.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id={clientId}&amp;amp;redirect_uri=https://c.na46.visual.force.com/apex/DropBoxPage&amp;amp;state=Mytesting&lt;/A&gt;') ;&lt;/P&gt;&lt;P&gt;return null;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;public void AccessToken()&lt;BR /&gt;{&lt;BR /&gt;//Getting access token from dropbox&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;String appKey='************';&lt;BR /&gt;String appSecreatKey='**********';&lt;BR /&gt;String tokenuri = '&lt;A href="https://api.dropbox.com/oauth2/token?grant_type=authorization_code&amp;amp;code='+code+'&amp;amp;redirect_uri=https://c.na46.visual.force.com/apex/DropBoxPage" target="_blank"&gt;https://api.dropbox.com/oauth2/token?grant_type=authorization_code&amp;amp;code='+code+'&amp;amp;redirect_uri=https://c.na46.visual.force.com/apex/DropBoxPage&lt;/A&gt;';&lt;BR /&gt;//&lt;A href="https://api.dropbox.com/1/oauth2/token?grant_type=authorization_code&amp;amp;code='+code+'&amp;amp;redirect_uri=https://c.ap1.visual.force.com/apex/DropboxPage" target="_blank"&gt;https://api.dropbox.com/1/oauth2/token?grant_type=authorization_code&amp;amp;code='+code+'&amp;amp;redirect_uri=https://c.ap1.visual.force.com/apex/DropboxPage&lt;/A&gt;';&lt;BR /&gt;HttpRequest req = new HttpRequest();&lt;BR /&gt;req.setEndpoint(tokenuri);&lt;BR /&gt;req.setMethod('POST');&lt;BR /&gt;req.setTimeout(60*1000);&lt;/P&gt;&lt;P&gt;Blob headerValue = Blob.valueOf('{appKey}' + ':' + '{appSecreatKey}');&lt;BR /&gt;String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);&lt;BR /&gt;req.setHeader('Authorization', authorizationHeader);&lt;BR /&gt;Http h = new Http();&lt;BR /&gt;String resp;&lt;BR /&gt;HttpResponse res = h.send(req);&lt;BR /&gt;resp = res.getBody();&lt;BR /&gt;System.debug('response='+resp);&lt;BR /&gt;JSONParser parser = JSON.createParser(resp);&lt;BR /&gt;while (parser.nextToken() != null) {&lt;BR /&gt;if ((parser.getCurrentToken() == JSONToken.FIELD_NAME)){&lt;BR /&gt;String fieldName = parser.getText();&lt;BR /&gt;parser.nextToken();&lt;BR /&gt;if(fieldName == 'access_token') {&lt;BR /&gt;accesstoken = parser.getText();&lt;BR /&gt;System.debug('accesstoken='+accesstoken);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;system.debug('accessToken:'+accessToken );&lt;BR /&gt;System.debug(' You can parse the response to get the access token ::: ' + resp);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can anybody tell me what is 'code' value at line&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;code = ApexPages.currentPage().getParameters().get('code') ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Help is highly appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 09:15:57 GMT</pubDate>
    <dc:creator>Tejas_99</dc:creator>
    <dc:date>2019-05-29T09:15:57Z</dc:date>
    <item>
      <title>Salesforce To dropbox file upload</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Salesforce-To-dropbox-file-upload/m-p/261185#M15231</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to upload a file from salesforce to Dropbox.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a class&amp;nbsp;in salesforce as per suggestions from the internet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public class dropBoxApi{&lt;BR /&gt;Public String code ;&lt;BR /&gt;Public String accesstoken;&lt;BR /&gt;public String fileBody{get;set;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;public dropBoxApi()&lt;BR /&gt;{&lt;BR /&gt;code = ApexPages.currentPage().getParameters().get('code') ;&lt;BR /&gt;System.debug('Code='+code);&lt;BR /&gt;if(code != '' &amp;amp;&amp;amp; code != null)&lt;BR /&gt;{&lt;BR /&gt;AccessToken() ;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;public PageReference DropAuth()&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;system.debug('UPLOAD'+accessToken );&lt;BR /&gt;//Authenticating&lt;BR /&gt;PageReference pg = new PageReference('&lt;A href="https://www.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id={clientId}&amp;amp;redirect_uri=https://c.na46.visual.force.com/apex/DropBoxPage&amp;amp;state=Mytesting" target="_blank"&gt;https://www.dropbox.com/1/oauth2/authorize?response_type=code&amp;amp;client_id={clientId}&amp;amp;redirect_uri=https://c.na46.visual.force.com/apex/DropBoxPage&amp;amp;state=Mytesting&lt;/A&gt;') ;&lt;/P&gt;&lt;P&gt;return null;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;public void AccessToken()&lt;BR /&gt;{&lt;BR /&gt;//Getting access token from dropbox&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;String appKey='************';&lt;BR /&gt;String appSecreatKey='**********';&lt;BR /&gt;String tokenuri = '&lt;A href="https://api.dropbox.com/oauth2/token?grant_type=authorization_code&amp;amp;code='+code+'&amp;amp;redirect_uri=https://c.na46.visual.force.com/apex/DropBoxPage" target="_blank"&gt;https://api.dropbox.com/oauth2/token?grant_type=authorization_code&amp;amp;code='+code+'&amp;amp;redirect_uri=https://c.na46.visual.force.com/apex/DropBoxPage&lt;/A&gt;';&lt;BR /&gt;//&lt;A href="https://api.dropbox.com/1/oauth2/token?grant_type=authorization_code&amp;amp;code='+code+'&amp;amp;redirect_uri=https://c.ap1.visual.force.com/apex/DropboxPage" target="_blank"&gt;https://api.dropbox.com/1/oauth2/token?grant_type=authorization_code&amp;amp;code='+code+'&amp;amp;redirect_uri=https://c.ap1.visual.force.com/apex/DropboxPage&lt;/A&gt;';&lt;BR /&gt;HttpRequest req = new HttpRequest();&lt;BR /&gt;req.setEndpoint(tokenuri);&lt;BR /&gt;req.setMethod('POST');&lt;BR /&gt;req.setTimeout(60*1000);&lt;/P&gt;&lt;P&gt;Blob headerValue = Blob.valueOf('{appKey}' + ':' + '{appSecreatKey}');&lt;BR /&gt;String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);&lt;BR /&gt;req.setHeader('Authorization', authorizationHeader);&lt;BR /&gt;Http h = new Http();&lt;BR /&gt;String resp;&lt;BR /&gt;HttpResponse res = h.send(req);&lt;BR /&gt;resp = res.getBody();&lt;BR /&gt;System.debug('response='+resp);&lt;BR /&gt;JSONParser parser = JSON.createParser(resp);&lt;BR /&gt;while (parser.nextToken() != null) {&lt;BR /&gt;if ((parser.getCurrentToken() == JSONToken.FIELD_NAME)){&lt;BR /&gt;String fieldName = parser.getText();&lt;BR /&gt;parser.nextToken();&lt;BR /&gt;if(fieldName == 'access_token') {&lt;BR /&gt;accesstoken = parser.getText();&lt;BR /&gt;System.debug('accesstoken='+accesstoken);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;system.debug('accessToken:'+accessToken );&lt;BR /&gt;System.debug(' You can parse the response to get the access token ::: ' + resp);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can anybody tell me what is 'code' value at line&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;code = ApexPages.currentPage().getParameters().get('code') ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Help is highly appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:15:57 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Salesforce-To-dropbox-file-upload/m-p/261185#M15231</guid>
      <dc:creator>Tejas_99</dc:creator>
      <dc:date>2019-05-29T09:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Salesforce To dropbox file upload</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Salesforce-To-dropbox-file-upload/m-p/261217#M15236</link>
      <description>It looks like the 'code' variable here would be the "authorization code" used during the OAuth app authorization "code" flow.&lt;BR /&gt;&lt;BR /&gt;You can find more information on how this works in the OAuth guide:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.dropbox.com/developers/reference/oauth-guide" target="_blank"&gt;https://www.dropbox.com/developers/reference/oauth-guide&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and the OAuth documentation:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#authorization" target="_blank"&gt;https://www.dropbox.com/developers/documentation/http/documentation#authorization&lt;/A&gt;</description>
      <pubDate>Thu, 18 Jan 2018 16:41:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Salesforce-To-dropbox-file-upload/m-p/261217#M15236</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-01-18T16:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Salesforce To dropbox file upload</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Salesforce-To-dropbox-file-upload/m-p/261752#M15263</link>
      <description>&lt;P&gt;Hi Greg,&lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you tell me where will I get authorization code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see in code I already have value for "code" variable before making any request to dropbox.&lt;/P&gt;&lt;P&gt;I already have app key and secret key and I can generate access key by clicking on generate access key button in app console but I don't know from where I will get authorization code.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 12:06:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Salesforce-To-dropbox-file-upload/m-p/261752#M15263</guid>
      <dc:creator>Tejas_99</dc:creator>
      <dc:date>2018-01-22T12:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Salesforce To dropbox file upload</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Salesforce-To-dropbox-file-upload/m-p/261820#M15273</link>
      <description>The authorization code is given from Dropbox during the OAuth app authorization flow. It would either be returned on the redirect URI, if used, or directly to the user on the Dropbox web site, if not. Please refer to the links in my last post for more information on how this works.&lt;BR /&gt;&lt;BR /&gt;The authorization code is a temporary code used to get an access token. Once you have an access token for the user, you no longer need an authorization code for the user.&lt;BR /&gt;&lt;BR /&gt;Also, if you only need to connect to your own account, you can just use the access token retrieved via the "Generate" button on the App Console as you mentioned. That directly returns an access token for your app and account, without going through the OAuth app authorization flow and getting an authorization code.</description>
      <pubDate>Mon, 22 Jan 2018 16:33:44 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Salesforce-To-dropbox-file-upload/m-p/261820#M15273</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-01-22T16:33:44Z</dc:date>
    </item>
  </channel>
</rss>

