locked
Azure App Service Authentication with Google / Facebook - register user on webapi backend RRS feed

  • Question

  • User1784932228 posted

    I have a webapi that is hosted on Azure. I'm trying to use the App Service authentication service for Google / Facebook. I've got it setup with Google and can see the google login page when I try to access this url

    https://myapp.azurewebsites.net/.auth/login/google

    Once I login with google, i see all my google information here:

    https://myapp.azurewebsites.net/.auth/me

    However, if i try to access one of the endpoints, i get an unauthorized error. For example, I'm using the Visual Studio WebAPI template project. It has the following endpoint:

    https://myapp.azurewebsites.net/api/Values

    That endpoint above gives me this error:

    <Error>
    <Message>Authorization has been denied for this request.</Message>
    </Error>
    The controller for that endpoint looks like this (again this is a pre-generated code from the Web API template):
    namespace WebApi.Controllers
    {
        [Authorize]
        [RoutePrefix("api/Account")]
        public class AccountController : ApiController
        {
            private const string LocalLoginProvider = "Local";
            private ApplicationUserManager _userManager;
    
            public AccountController()
            {
            }



    I believe there needs to be a registration process done first on the webapi backend. For example, to call the following endpoint:

    https://myapp.azurewebsites.net/api/Account/RegisterExternal

    Does this registration process need to take place? 

    If so, how should my client do the POST so it gets through the Azure authentication service?

    Thursday, July 14, 2016 12:44 AM

All replies