Skip to content

Client Applications

Hemanth Chittanuru edited this page Aug 4, 2020 · 2 revisions

Instantiating an Application

Pre-requisites

Before instantiating your app with MSAL Go,

  1. Understand the types of Client applications available- Public Client and Confidential Client applications.
  2. You'll need to register the application with Azure AD. You will therefore know:
    • Its clientID (a string representing a GUID)
    • The identity provider URL (named the instance) and the sign-in audience for your application. These two parameters are collectively known as the authority.
    • Possibly the TenantID in the case you are writing a line of business application (just for your organization, also named single-tenant application)
    • In case it's a confidential client app, its application secret (clientSecret string) or certificate
    • For web apps, you'll have also set the redirectUri where the identity provider will contact back your application with the security tokens.

Instantiating a Public Client application

publicClientApp, err := msalgo.CreatePublicClientApplication(clientID, authority)

Instantiating a Confidential Client application

To instantiate a confidential client application, you will need a client secret, certificate or assertion JWT.

  1. Instantiating with client secret
confidentialClientApp := msalgo.CreateConfidentialClientApplicationFromSecret(
        clientID, authority, clientSecret)
  1. Instantiating with certificate
file, err := os.Open(keyFile)
if err != nil {
    log.Fatal(err)
}
defer file.Close()
key, err := ioutil.ReadAll(file)
if err != nil {
    log.Fatal(err)
}
confidentialClientApp := msalgo.CreateConfidentialClientApplicationFromCertificate(
    clientID, authority, thumbprint, key)
  1. Instantiating with assertion JWT
confidentialClientApp := msalgo.CreateConfidentialClientApplicationFromAssertion(
    clientID, authority, assertion)

Getting Started with MSAL Go

  1. Home
  2. Build and Test
Clone this wiki locally