Skip to content

Instantly share code, notes, and snippets.

@jamessdixon

jamessdixon/FSAuth0

Created Feb 21, 2019
Embed
What would you like to do?
Auth0 with F#
namespace sameroom.mobile.iOS
open System
open Xamarin.Forms
open sameroom.mobile
open Auth0.OidcClient
type LoginParameters = { audience : string }
type AuthenticationService() =
let authenticate =
async {
let options = new Auth0ClientOptions()
options.Domain <- Support.authenticationConfig.Domain
options.ClientId <- Support.authenticationConfig.ClientId
let client = new Auth0Client(options)
//let result = cient.LoginAsync({ audience = Support.authenticationConfig.Audience })
let! result = client.LoginAsync({ audience = Support.authenticationConfig.Audience }) |> Async.AwaitTask
return result
}
interface IAuthenticationService with
member this.Authenticate =
let result = authenticate |> Async.RunSynchronously
match result.IsError with
| true ->
AuthenticationResult.Bad {Error=result.Error}
| false ->
AuthenticationResult.Good {IdToken = result.IdentityToken; AccessToken=result.AccessToken; UserClaims=result.User.Claims;}
module AuthenticationService =
[<assembly: Dependency(typeof<AuthenticationService>)>]
do()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment