AzureAD/microsoft-authentication-library-for-go

[Bug] confidential.WithAuthority is undefined

isabellachen opened this issue · 5 comments

Which version of MSAL Go are you using?
v1.0.0

Where is the issue?

  • Confidential client
    • Authorization code flow
    • Client credentials:
      • client secret
      • client certificate
  • Token cache serialization
    • In-memory cache
  • Other (please describe)

Is this a new or an existing app?
This is a new app

What version of Go are you using (go version)?

$ go version go1.20.1

What operating system and processor architecture are you using (go env)?
darwin/arm64

Repro
image

image

Expected behavior
I am following the docs to set up a confidential client app: https://pkg.go.dev/github.com/AzureAD/microsoft-authentication-library-for-go@v1.0.0#section-readme

Sadly WithAuthority does not exist in the confidential package.

Hmm, I think this is more a documentation thing. The args for confidential.New() are different from the documentation on the main page.

Would this be the right?

func (a *authorizationHandlers) GetPowerBIEmbedToken(w http.ResponseWriter, r *http.Request) {
	cred, err := confidential.NewCredFromSecret("client_secret")
	if err != nil {
		fmt.Errorf("could not create a cred from a secret: %w", err)
	}

	confidentialClientApp, err := confidential.New(
		"https://login.microsoftonline.com/<your tenant>",
		"powerBI_clientID",
		cred,
	)
}

It works. I guess the docs need to be updated.

Just had exactly the same issue with the documentation - doesn't seem to have been fixed, but the issue is closed?

I suppose its more a docs need to be fixed rather than a bug. I was able to create the confidential client app with the code I shared above. Looks like they have removed the .WithAuthority method.

I suppose its more a docs need to be fixed rather than a bug. I was able to create the confidential client app with the code I shared above. Looks like they have removed the .WithAuthority method.

Yes, upgraded from ver.7 and had the same issue. Didn't find anything in the release note but your post is very helpful.