Q:

Giraffe + GitHub OAuth flow in AspNet Core redirect loop

I've created a test application in which I want to use the GitHub Oauth flow, example code here:

Routing is like this:
let webApp =
    logRequest >=> choose [
        GET >=> 
            choose [
                route "/" >=> indexHandler "world"
                route "/login" >=> loginHandler
                route "/signin-github" >=> signinHandler
            ]
        mustBeLoggedIn >=>
            GET >=>
                choose [
                    route "/api" >=> indexHandler "authenticated world"
                ]    
        setStatusCode 404 >=> text "Not Found" ]

When I call /api, if will call challenge command with the /login route:
let mustBeLoggedIn : HttpHandler =
    requiresAuthentication (redirectTo true "/login")

let loginHandler = 
    challenge "GitHub"

The flow is initiated and everything seems to be going well, until the OnCreatingTicket event is triggerd. This causes a call to the https://api.github.com/user, twice for some reason. I configured a callbackpath:
options.CallbackPath <- new PathString("/signin-github")

With Fiddler I can see above url beeing called then but is redirected to /login (that redirects back to GitHub, hence the loop) and I don't know why and what redirects. The /signin-github doesn't require authentication. I added some logging but the only route called is /login, so it seems the redirect is before Giraffe routing is done. I have no clue.
Edit 6/14/2018:
Working solution here: https://github.com/EelcoMulder/GiraffeOAuth

A:

Someone (damukles) on the giraffe channel on the functional programming solved this for me, it turned out to be a case of less is and more and a mistake I made. the mustBeLoggedIn handler should look like this:
    let mustBeLoggedIn : HttpHandler =
        requiresAuthentication (challenge "GitHub")

and the routes "/login" and "/signin-github" could be removed, apparently the auth library handled more than before. I will write a blog about this, will update this post when done.

