# Login with Social providers + Auth0 + Web Api Backend

**URL:** <https://community.auth0.com/t/login-with-social-providers-auth0-web-api-backend/7054>\
**Category:** Get Help\
**Tags:** api-authorization, login\
**Created:** [June 14, 2017, 5:44am UTC](https://community.auth0.com/t/login-with-social-providers-auth0-web-api-backend/7054 "2017-06-14T05:44:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kusanagi2k2](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kusanagi2k2](https://community.auth0.com/u/kusanagi2k2)\
**Post date:** [June 14, 2017, 5:44am UTC](https://community.auth0.com/t/login-with-social-providers-auth0-web-api-backend/7054/1 "2017-06-14T05:44:06Z")

</div>

Hello!

I am new using auth0 I need to show a demo to my clients using auth0 to solve this problem:

I need to access from different apps(IOS,Android, UWP, desktop) to my backend ([Asp.Net](http://Asp.Net)  
Web Api) using social providers like facebook (for now and later twitter or another) all the users must be stored in my custom database.  
I configured my custom database now I can login, verify, create etc…  
I made some rules to enrich my login info.  
I created a new API following this tutorial:  
[ASP.NET Web API (OWIN): Authorization - Auth0 Docs](https://auth0.com/docs/quickstart/backend/webapi-owin/00-getting-started)  
I can do the test successfully using PostMan to my backend.

I am using RS256 algorithm

I created a new UWP app I installed the nuget package  
Auth0 OIDC Client for Universal Windows Platform (UWP) applications  
I used the client Id of my new client(myapi-test) and the secret key  
var client = new Auth0Client(new Auth0ClientOptions  
{  
Domain = “[xxx.auth0.com](http://xxx.auth0.com)”,  
ClientId = “xxxxxxxx”,  
ClientSecret= “xxxxxxxx”  
});

```
            var loginResult = await client.LoginAsync();

```

I could see in the error log I need to add to the client myapi-test(no interactive) the callback  
[https://xxxx.auth0.com/mobile](https://xxxx.auth0.com/mobile)  
because I got this error in the log:  
**Callback URL mismatch. [https://xxx.auth0.com/mobile](https://xxx.auth0.com/mobile) is not in the list of allowed callback URLs**

Now I run again my UWP and I can see the login page I used facebook and I got my token.

I guess with this token I can make request to my backend(Web Api) but always I get the error

```
{
    "message": "Authorization has been denied for this request."
}

```

like I said I am new using Auth0 someone can help me? I want to use the token that I get from my login page of my mobile apps to make requests to my Backend.  
I don’t know if I am missing something.

Thank you!

---

<div class="post-metadata">

**Author:** ![jerrie](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jerrie/32/5898_2.png) [@jerrie](https://community.auth0.com/u/jerrie)\
**Post date:** [June 14, 2017, 7:51am UTC](https://community.auth0.com/t/login-with-social-providers-auth0-web-api-backend/7054/2 "2017-06-14T07:51:19Z")

</div>

Which token are you passing to the API? You need to pass the `AccessToken` along,

If that does not work, please post the `AccessToken` here so I can have a look at it.

Also, our Web API quickstart has a troubleshooting guide which helps you work through these issues:

> **[Auth0 ASP.NET Web API (OWIN) SDK Quickstarts: Troubleshooting](https://auth0.com/docs/quickstart/backend/webapi-owin/03-troubleshooting)**
>
> This document will help you troubleshoot your configuration if you get a 401 (Unauthorized) response from your API.

---

<div class="post-metadata">

**Author:** ![kusanagi2k2](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kusanagi2k2](https://community.auth0.com/u/kusanagi2k2)\
**Post date:** [June 14, 2017, 8:06am UTC](https://community.auth0.com/t/login-with-social-providers-auth0-web-api-backend/7054/3 "2017-06-14T08:06:47Z")

</div>

Thank you! for your response I checked the access \_token and it is too short 😕  
2SbyLDdM0\_xLRkfx  
Now I am sure I am doing something wrong

---

<div class="post-metadata">

**Author:** ![jerrie](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jerrie/32/5898_2.png) [@jerrie](https://community.auth0.com/u/jerrie)\
**Post date:** [June 14, 2017, 8:42am UTC](https://community.auth0.com/t/login-with-social-providers-auth0-web-api-backend/7054/4 "2017-06-14T08:42:33Z")

</div>

If it is too short, it is because you are not passing the `audience`. See the code snippet on this page for how you need to pass the `audience`  
[https://auth0.github.io/auth0-oidc-client-net/documentation/advanced-scenarios/api-authorization.html](https://auth0.github.io/auth0-oidc-client-net/documentation/advanced-scenarios/api-authorization.html)

The `audience` should be the **API Identifier** for your API

---

<div class="post-metadata">

**Author:** ![kusanagi2k2](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kusanagi2k2](https://community.auth0.com/u/kusanagi2k2)\
**Post date:** [June 14, 2017, 8:56am UTC](https://community.auth0.com/t/login-with-social-providers-auth0-web-api-backend/7054/5 "2017-06-14T08:56:15Z")

</div>

Ok Thank you for your help.  
I got the access\_ token too short from my UWP application.  
I used Post Man using a test request to my localhost environment and I can get the expected results.  
The problem is when I use my UWP App and I try to login using Facebook.

this is my code :

```
var client = new Auth0Client(new Auth0ClientOptions
            {
                
                Domain = "xxxx.auth0.com",
                ClientId = "xxxxxx",
                ClientSecret= "xxx"
            });

            var loginResult = await client.LoginAsync();

```

I think the issue is from my client-test (non interactive) I am not sure.  
the login result is:  
access\_token:BJFpgIp8P3EL8eIR  
user\_id:null  
Error:null  
User: I can see the data and the flag IsAuthenticated is True.

I am using the domain & clientId of my client(non interactive)

---

<div class="post-metadata">

**Author:** ![kusanagi2k2](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kusanagi2k2](https://community.auth0.com/u/kusanagi2k2)\
**Post date:** [June 14, 2017, 9:07am UTC](https://community.auth0.com/t/login-with-social-providers-auth0-web-api-backend/7054/6 "2017-06-14T09:07:16Z")

</div>

I can see in the IdentityToken property I got all the profile data of the user.

---

<div class="post-metadata">

**Author:** ![jerrie](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jerrie/32/5898_2.png) [@jerrie](https://community.auth0.com/u/jerrie)\
**Post date:** [June 14, 2017, 9:14am UTC](https://community.auth0.com/t/login-with-social-providers-auth0-web-api-backend/7054/7 "2017-06-14T09:14:45Z")

</div>

Did you look at this page I posted above?  
[https://auth0.github.io/auth0-oidc-client-net/documentation/advanced-scenarios/api-authorization.html](https://auth0.github.io/auth0-oidc-client-net/documentation/advanced-scenarios/api-authorization.html)

You need to pass `audience` when calling `LoginAsync()`

---

<div class="post-metadata">

**Author:** ![kusanagi2k2](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kusanagi2k2](https://community.auth0.com/u/kusanagi2k2)\
**Post date:** [June 14, 2017, 9:26am UTC](https://community.auth0.com/t/login-with-social-providers-auth0-web-api-backend/7054/8 "2017-06-14T09:26:10Z")

</div>

Thank you! I didn’t see that now I can call my API.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:54am UTC](https://community.auth0.com/t/login-with-social-providers-auth0-web-api-backend/7054/9 "2018-03-02T05:54:37Z")

</div>


