Skip to content

mjarosie/Fable.OidcClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fable.OidcClient Nuget

Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client applications written in F#. It's a Fable binding for oidc-client javascript library.

How to start using this package

In a directory where your project's .fsproj file is:

dotnet add package Fable.OidcClient

In a directory where your project's package.json is:

npm install oidc-client 

Examples

Repositories showing examples of using Fable.OidcClient with:

Initialise the User Manager

open Fable.OidcClient
open Fable.Core.JsInterop // Required for the "!!" operator.

let settings: UserManagerSettings = 
    !!{| 
        authority = Some "https://localhost:5001"
        client_id = Some "js"
        redirect_uri = Some "https://localhost:5003/callback.html"
        response_type = Some "code"
        scope = Some "openid profile scope1"
        post_logout_redirect_uri = Some "https://localhost:5003/index.html"
        
        filterProtocolClaims = Some true
        loadUserInfo = Some true
    |}

let mgr: UserManager = Oidc.UserManager.Create settings

// From here you can call
// mgr.signinRedirect() to redirect to login page,
// mgr.signoutRedirect() to redirect to logout page,
// mgr.getUser() to retrieve user's details,
// etc...

Handle the OpenId Connect redirect protocol

open Fable.OidcClient
open Fable.Core.JsInterop

let mgr: UserManager = Oidc.UserManager.Create !!{| response_mode = Some "query" |}

promise {
    console.log "mgr.signinRedirectCallback()"
    let! user = mgr.signinRedirectCallback()
    console.log (sprintf "%A" user)
    window.location.href <- "index.html"
} |> ignore

About

Fable binding for oidc-client-js javascript library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages