You need to sign in to do that
Don't have an account?

dropbox integration with salesforce
Hi All,
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 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
Example:-
{"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.
Thanks
Satheesh
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 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
Example:-
{"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.
Thanks
Satheesh
Is this code working?
also this
should be hard-coded?https://www.codekiat.com/2019/07/salesforce-dropbox-integration-a-complete-guide.html
--
Naveen K N