Aspnetcore.docs: How to bring the external login button to another page?

Created on 10 May 2018  Â·  6Comments  Â·  Source: dotnet/AspNetCore.Docs

The document is really great and simple to get the function started. But it still lacks the details about the codes behind the scenes. I'm trying to get the flow of all the generated pages and I have to admit that it's not an easy task... Well, I want to bring the "Facebook" login button to the home page, not inside the Login page.

On my homepage, I'm trying to redirect to the ExternalLogin like the button in the Login page like this:

<form asp-page="./Account/ExternalLogin" asp-route-returnUrl="" method="post" class="form-horizontal">
    <button type="submit" class="btn rounded blue">Login with Facebook</button>
</form>

But it doesn't work :( Clicking the button on the front page, it redirects me to the Login page again.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

P4 Source - Docs.ms

Most helpful comment

@nguyenlamlll The template code is not simple. Would you mind asking this question on Stack overflow? The document is not meant to explain all the code in the templates, but how to use FB auth.

All 6 comments

@nguyenlamlll The template code is not simple. Would you mind asking this question on Stack overflow? The document is not meant to explain all the code in the templates, but how to use FB auth.

Thanks, I see. I will tinker on my own a bit then will see to StackOverflow for more helps.

Can you post the SO link here?

Hey, this one is really stupid me but I found out that the external login button is totally moveable and we don't have to configure the generated code flow. I just missed name and value of the form.

Here is the working button that I placed on the homepage

<form asp-page="./Account/ExternalLogin" method="post" class="form-horizontal">
    <button type="submit" name="provider" value="Facebook" class="btn rounded blue">
        Login with Facebook
    </button>
</form>

+100 tutorial is nice but it's not documentation. It's a quick start guide to test a feature. Adding a FB login into an existing site isn't quite clear. Obviously calling AddFacebook and setting AppId and AppSecret isn't enough. We should set a login url and a callback url and the article says nothing about it. Please reconsider your approach to documentation articles - it's not a first time I encountered a "quick-start" style. It'd be much more useful to have comprehensive description without depending on magic in templates.
Another issue - dependency on AddIdentity - how can I add a FB login w/o Ñ„ full-fledged Identity DB (I have my own one)?

this is why i hate projects template they abstract whats going on under the hood and implements bad bad practices and the programers follows and implements insecure code

Was this page helpful?
0 / 5 - 0 ratings