2

I am trying to implement a solution to integrate salesforce with Google Drive or Dropbox. The question that i have is:

Does someone have a tried and tested design pattern for using externals API's like google drive? What I am looking for is something which can be reused for any API's using oauth.

Thanks

6
  • Do you want to know how to integrate salesforce with google drive or you want generalized code which works for multiple externals api's
    – Peeyush
    Commented Feb 3, 2016 at 10:24
  • I am looking at design pattern which can be used with multiple external apis.
    – Prady
    Commented Feb 3, 2016 at 10:27
  • I think there is no such solution available. Every site or platform has there own design pattern and api's to integrate with them. So you can make generalized classes for a particular api like Google drive and use it in multiple pages or multiple orgs. But you can't have such solution which will work for multiple api's
    – Peeyush
    Commented Feb 3, 2016 at 10:33
  • If you want to know how to integrate with Google Drive OR Dropbox OR Facebook then please update your question
    – Peeyush
    Commented Feb 3, 2016 at 10:36
  • I am sure they do, but the oauth dance would mostly remain the same. Would you store the access token/authorization code onto a custom setting or custom object? There would also be methods for refreshing the authorization code. All these would be common for any api, ofcourse the urls would be different. i am just looking for a design pattern not actual implementation which uses the best practices
    – Prady
    Commented Feb 3, 2016 at 10:50

2 Answers 2

3

The platform includes Authentication Providers that you can configure to manage authentication with third-party sites. You don't need to handle the OAuth protocol flow, or store the resulting tokens - the platform does it all for you. I've done this in the past with Nest, Automatic, Google and other providers.

The blog entry, Automatic for the People, Redux – Connecting your Car to the Salesforce1 Platform, gives step by step instructions on creating an Auth Provider specifically to connect to an API provider (as opposed to single sign-on) and provides example code for retrieving data from Automatic. You should be able to adapt it to your use case.

0

Platform like google and other are basically works on Auth 2.0 protocol where you have to create some HTTP request with some end point and with a particular set of parameters.

Also these process are two steps process in first step you have to get Accesstoken and in second step have to hit a particular API by using this Access token.

So you can create some methods like one method to create a request in which you will pass an end point, client Id, client Secret.

Secondly you will create a method which will create encoding parameters which you need to send in your HTTP request. This method will receive three parameter one is for parameter name, second is for parameter value and third one is for encoding type which need to be done on these parameters.

Also you can follow below link as google drive integration code is mentioned here. http://forceguru.blogspot.in/2014/05/google-drive-authentication-in.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .