I'm trying to login to Salesforce in a Xamarin app through Google in order to get a valid bearer token to interact with my custom Salesforce REST API. It works just fine if I point Xamarin.Auth to Salesforce's standard OAuth2 URLs. However, I'd like to log in with Google.

My desired flow is this:

  • Xamarin.Auth determines that the app doesn't have a valid access/refresh token
  • A window pops up with a web view that takes me to Google's sign in page
  • After user gives permissions, Google redirects to Salesforce, which uses the information from Google to link the user to a Salesforce user
  • Salesforce returns an access/refresh token to Xamarin.Auth that can be used to query my custom Salesforce REST API

All the articles I can find talk about either logging into Salesforce through Google on the web or talking with Salesforce from a Google product. I've configured a Google Authentication Provider and a custom Google Cloud app, have a working custom registration handler, and I can go to the "Single Sign-On Initialization URL" and log into the Google and have it log me in to my Salesforce account on the web, so I feel that I'm close. My confusion lies in which endpoint to use for what.

Should I use the Google Authorize URL (https://accounts.google.com/o/oauth2/v2/auth) to start the flow in Xamarin.Auth? One of the Salesforce OAuth2 urls? Or the OAuth-Only Initialization URL from the custom authentication provider in the Salesforce Settings dashboard? It seems like there's some combination of the above that should work. Any help would be much appreciated! Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.