0

I am using the xamarin.auth to call salesforce api to finish my user authentication on my UWP app.

I setup my SalesForceRedirectUri to myapp:/oauth2Callback, but after the authentication (when I used the correct user name and password), the app shows: you will need a new app to open this myapp.

I googled and seem I need to:

  1. register your app to be the default handler for a URI scheme name by registering a protocol in the package manifest

  2. updating the Application.OnActivated event handler

But when I do 1. I don't know what should I put in the .appmanifest file. Especially what should I put as Name of protocol: (they say for google it is client id but for salesforce, the client id is different and doesn't match the format)

 <uap:Extension Category="windows.protocol">
     <uap:Protocol Name="" />
 </uap:Extension>
  1. I don't know which page I should redirect to. if I redirect to MainPage.xaml (entry point of the project), it shows the login page again. if I redirect to the landing page in the common code (the code used by both iOS project and UWP project.) it gives me an exception:

System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

Thank you in advance for giving me any advise or let me know if I am going to the wrong direction.

1 Answers1

0

Just pick a name you like, "myapp" is fine, or "myawesomeapp" to make it less likely to conflict with other apps.

It is just a contract between your app and the OS, basically you are asking the OS to launch/activate your app when something like "myawesomeapp://xxx" is requested.

<uap:Extension Category="windows.protocol">
  <uap:Protocol Name="myawesomeapp" />
</uap:Extension>

And for the 2nd question about where to redirect to, this depends on how the MainPage/LandingPage and how the app's flow is designed.

For example, MainPage can be designed in this way that the login dialog is just an overlay and will be dismissed when after being authenticated, and user continues to interact with MainPage to input some information before navigating to Landing Page, in this case, the redirect page should be the MainPage.

kennyzx
  • 12,845
  • 6
  • 39
  • 83