0
51%
MIT
bs-msal
2.0.0
Bucklescript/ReasonML bindings for https://www.npmjs.com/package/msal (Microsoft Authentication Library Preview for JavaScript)

bs-msal

DEPRECATED. Please refer to https://github.com/SeaMonster-Studios/sms-reason

Bindings for microsoft-authentication-library-for-js (msal)

Usage

You'll notice that the intilization function has been simplified from UserAgentApplication to initApp, and that all parameters are named. All optional properties on the optional options object in the original msal have been moved to the root of the function call, also as named parameters. The only required parameters are clientId, authority, and tokenReceivedCallback.

Example

  • RE
  • ML
let authApp =
      Msal.initApp(
        ~clientId="CLIENT_ID_HERE",
        ~authority=
          "B2C_AUTHORITY_HERE",
        ~tokenReceivedCallback=
          (_errorDesc, _token, error, _tokenType) => {
            Js.log("Error in tokenReceivedCallback:");
            Js.log(error);
          },
        ~redirectUri="http://YOU_REDIRECT_URI",
        ~postLogoutRedirectUri="http://YOU_LOGOUT_REDIRECT_URI",
        ~storeAuthStateInCookie=false,
        ~validateAuthority=false,
        ~cacheLocation=`localStorage,
        (),
      );

    Js.log(authApp |> Msal.logger |> Msal.correlationId);
let authApp =
  Msal.initApp ~clientId:"CLIENT_ID_HERE" ~authority:"B2C_AUTHORITY_HERE"
    ~tokenReceivedCallback:(fun _errorDesc  ->
                              fun _token  ->
                                fun error  ->
                                  fun _tokenType  ->
                                    Js.log "Error in tokenReceivedCallback:";
                                    Js.log error)
    ~redirectUri:"http://YOU_REDIRECT_URI"
    ~postLogoutRedirectUri:"http://YOU_LOGOUT_REDIRECT_URI"
    ~storeAuthStateInCookie:false ~validateAuthority:false
    ~cacheLocation:`localStorage ()
let _ = Js.log ((authApp |> Msal.logger) |> Msal.correlationId)