function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
satheesh8.k1.3890099515516848E12satheesh8.k1.3890099515516848E12 

dropbox Integration

Hi All,

Please help me regarding integration between dropbox and salesforce ,

This Below link very useful to me  :
http://forceguru.blogspot.in/2014/05/dropbox-authentication-in-salesforce.html

but i am unable to get user profile information or app information from dropbox, please help me how to get those information , 

I did connection between salesforce to dropbox , i have access token ,api key, api secrete all things ,
but i don't know how pass request and how to get response as user details .


Please help me
Thanks
Satheesh

 
Krishna SambarajuKrishna Sambaraju
Here is an example to get the user details using HttpRequest.
string endPointUrl = your_instance_url + '/services/data/v30.0/query?q=SELECT+ID,+Profile.Name+FROM+User+WHERE+Username=\'username_of_user_record\'';
HttpRequest req = new HttpRequest();
req.setEndPoint(endPointUrl);
req.setHeader('Authorization', 'Bearer ' + accessToken);
req.setTimeout(60000);
req.setMethod('GET');
req.setHeader('Content-Type','application/json');
HttpResponse res = new Http().send(req);
system.debug('Response: ' + res.getBody());
Change your_instance_url and username_of_user_record accordingly or the where clause according to your requirement. You can see the response in the debug. You can parse the response body using jsonparser.

Hope this helps.
satheesh8.k1.3890099515516848E12satheesh8.k1.3890099515516848E12
Hi Krishna,

Thank you for your response.

VF Page:

<apex:page controller="DropboxController">
<apex:form>
    <apex:pageblock>
        <apex:commandbutton action="{!DropAuth}" value="Dropbox Authentication">
    </apex:commandbutton></apex:pageblock>
</apex:form>
</apex:page>

apex:-

public class DropboxController
{
    //Fetched from URL
    String code ;
    
    public DropboxController()
    {
        code = ApexPages.currentPage().getParameters().get('code') ;
        //Get the access token once we have code
        if(code != '' && code != null)
        {
            AccessToken() ;
        }
    }
    
    public PageReference DropAuth()
    {
        //Authenticating
        PageReference pg = new PageReference('https://www.dropbox.com/1/oauth2/authorize?response_type=code&client_id=vaabb5qz4jv28t5&redirect_uri=https://c.ap1.visual.force.com/apex/DropboxPage&state=Mytesting') ;
        return pg ;
    }
    
    public void AccessToken()
    {
        //Getting access token from dropbox
        String tokenuri = 'https://api.dropbox.com/1/oauth2/token?grant_type=authorization_code&code='+code+'&redirect_uri=https://c.ap1.visual.force.com/apex/DropboxPage'; 
        HttpRequest req = new HttpRequest();
        req.setEndpoint(tokenuri);
        req.setMethod('POST');
        req.setTimeout(60*1000);
          
        Blob headerValue = Blob.valueOf('vaabb5qz4jv28t5' + ':' + 'dpmmll522bep6pt');
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        Http h = new Http();
        String resp;
        HttpResponse res = h.send(req);
        resp = res.getBody();
        
        System.debug(' You can parse the response to get the access token ::: ' + resp);
   }
}


I changed the key,secrete and redirect url,later i run the code ,
Now i got the response from debug log

{"access_token": "fdNB-pM_uYsAAAAAAAAANrefVrISVc9rcvRdrUmHqq46W26cDanUSzgzUwIQHr_", "token_type": "bearer", "uid": "282967343"}

but i did not get user profile infomation and app details from dropbox,

If you don't mind ,please help me i am new for integration that's why i am asking again ,
as well as please explain about endpoint url with example.

Thanks
Satheesh

 
Krishna SambarajuKrishna Sambaraju
Your question wasn't clear to me. Are you trying to get the User details from a Salesforce instance using a REST call?
satheesh8.k1.3890099515516848E12satheesh8.k1.3890099515516848E12
Hi Krishna ,

Please help me ,

I want to get user details from dropbox and display it in salesforce.

Another requirement is, upload a files from salesforce and upload it in dropbox . and get the files or images from dropbox and display it in salesforce.

I hope you can help me

Thanks
Satheesh
Krishna SambarajuKrishna Sambaraju
Hi Satheesh,

After getting the access token from the first call, use the following method in your controller to get the account info from drop box.
public void getAccountInfo()
   {
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://api.dropbox.com/1/account/info');
        req.setHeader('Authorization', 'Bearer ' + token);
        req.setMethod('GET');
        req.setTimeout(60000);
        Http h = new Http();
        HttpResponse res = h.send(req);
        string resp = res.getBody();

        System.debug(' Account Information :: ' + resp);
   }

For more information on how to get and upload files refer the core api of dropbox. Here is the link for the same.
https://www.dropbox.com/developers/core/docs

Hope this helps.
satheesh8.k1.3890099515516848E12satheesh8.k1.3890099515516848E12
Hi Krishna

Thank you for your response

Thanks
satheesh
Naveen KNNaveen KN
A detailed post on integrating Salesforce with Dropbox

https://www.codekiat.com/2019/07/salesforce-dropbox-integration-a-complete-guide.html

--
Naveen K N