+ Start a Discussion

dropbox integration with salesforce

Hi All,

VF Page:

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


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()
        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();
        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 got the key,secrete and redirect url from dropbox , and set it in the above code
Now i got the response as a access token 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,

Please help me i am new for integration
as well as please explain about how to pass endpoint url with example.

krishna Bidwai 54krishna Bidwai 54

Is this code working? 

also this

Blob headerValue = Blob.valueOf('vaabb5qz4jv28t5' + ':' + 'dpmmll522bep6pt');
should be hard-coded?
Naveen KNNaveen KN
A detailed post on integrating Salesforce with Dropbox


Naveen K N