Question

Je suis assez nouveau dans Salesforce et leur langue Apex. J'ai lu une documentation et essayé l'intégration entre Google et Salesforce.

Je me demande s'il est possible d'imiter un jeton Auth de Google à Salesforce?

J'essaie de lire une feuille de calcul Google, puis de remplir automatiquement un objet Salesforce. La connexion de l'utilisateur sera toujours la même / universelle pour cette feuille de calcul, j'ai donc les informations d'identification requises pour me connecter. Je travaille à partir de l'échantillon qui nécessite un VisualForce, et je me demande comment ferais-je automatiquement le jeton ID de session dont l'API de la feuille de calcul Google a besoin.

Des idées?

Était-ce utile?

La solution

The old-school, hard way would be to send a login() call to the API (available through SOAP messages). Salesforce API is well documented and plenty of examples are available (both in programming languages and for raw XML requests/responses).

But I have no idea what possibilities you have from Google side, if it's only JavaScript then you might not be able to send and retrieve AJAX-like calls to another domain...

Recently another option emerged and that is REST API (no SOAP needed). Looks more promising and easier in my opinion. Quick intro is available here and you'll find more documentation on the bottom of the page.

Last but not least - 2 interesting links: http://code.google.com/apis/gdata/articles/salesforce.html for some integration tutorial and built-in integration offered by Salesforce: http://www.salesforce.com/assets/pdf/datasheets/SalesforceGoogleApps.pdf

Autres conseils

I've used custom settings to do this. Use OAuth to get a token for Google, then store that token in Salesforce custom settings (Setup-Develop-Custom Settings). You can then retrieve the token for callouts to Google from that custom setting for any user needing access to Google Apps. The downside is, every user will authenticate as your custom setting token user. The upside is that they won't need to individually authenticate. Custom settings are retrievable via Apex using a simple getter, and live as Apex-like objects.

Also keep in mind, Google requires each service to use it's own token. So, if your user wants to use Calendars and Spreadsheets, that's two separate tokens that will need to be stored and retrieved for the callout.

I generally allow users to create their own authenticated session tokens via OAuth if they want to do that, then failover to the custom settings to get the general admin token if necessary.

Are you trying to log into Google Apps from SFDC? There are options for Google Apps within Salesforce, go to Setup > Administration Setup > Google Apps > Settings. I've not used this and it requires some setup, but thought I'd point it out. Aside from that I can only blurt out OAuth (getting users to authenticate with Google from within Salesforce when trying to access Google Apps) and SSO (which I know can be used to authenticate from an external system, though not sure if it works the other way).

Look into the "Named Credentials" menu in salesforce setup. There, you can store auth credentials for the services accessed via Apex:

"A named credential specifies a callout endpoint and its required authentication parameters. When setting up callouts, avoid setting authentication parameters for each callout by referencing named credentials."

a username/pass combo can be used, or a certificate, or an AWS signature, and there is a JWT option..

Help docs: https://help.salesforce.com/articleView?id=named_credentials_about.htm&type=5

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top