Base solution for your next web application
Open Closed

Facebook login for Xamarin app #2266


User avatar
0
ianmark89 created

I want to make my native mobile app (Xamarin) can login by facebook, is there any sample code or how can I do it?


8 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    This is possible but you need to update your solution to latest version of AspNet Zero. Then you need to follow these steps. We used same steps for Facebook Auth in our Angular2 app.

    1. Make a request to Facebook from your Xamarin App and get an access token (or access code, I dont know the parameter name very well :)) using user's facebook credentials.

    2. Then you need to call "/api/TokenAuth/ExternalAuthenticate" with the access code you get from facebook. other parameters will be authProvider: "Facebook", providerKey:"Your App's provider key". providerAccessCode:"access token you get from facebook".

    This api method will return you an accessToken, and you can call other API methods using this access token. You can see definition of ExternalAuthenticate in below screenshot.

  • User Avatar
    0
    ianmark89 created

    Hi,

    Thanks for your answer.

    How system detect tenant who make the request? I think method GetTenancyNameOrNull cannot get tenantId in AbpSession.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I forgot to mention that. If you are using subdomain for each tenant, you can make request to the for example tenant1.yoursite.com/.... If you are not using this, then you need to add "Abp.TenantId" header to your request.

  • User Avatar
    0
    jeromevoxteneo created

    Hello,

    I have the same need in my aspnet zero MVC / Jquery application but I don't have the api endpoint available.

    What is the version of Abp Zero needed ?

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Your project must contain same API's. Please select the correct version for your project type <a class="postlink" href="https://aspnetzero.com/Documents/Development-Guide">https://aspnetzero.com/Documents/Development-Guide</a> and go to Token Based Authentication section.

    Please let us know if it does not work for you.

  • User Avatar
    0
    jeromevoxteneo created

    Hello,

    We have the Token Based authentification, but only for the standard login (so with username and password).

    But that's ok, we take the /api/TokenAuth/ExternalAuthenticate implementation from the Core.Web project (in ASP.NET Core project of aspnet zero template) and copy it inside of AccountController of Web API project (inside on ASP.NET MVC Jquery project)

    We test it from our Xamarin project and now it's ok.

    We need to think now about a system of renew token and alternative to not store ProviderKey inside of the mobile app.

    Best regards,

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thank you for your feedback.

  • User Avatar
    0
    scharada created

    Hi. Could you please share what you did to make it work ? i am having the same requirement and it is really not clear what calls to make first and what parameters to use ...

    thank you