in pkg/internal/pop/msal_public.go [50:85]
func AcquirePoPTokenByUsernamePassword(
context context.Context,
popClaims map[string]string,
scopes []string,
username,
password string,
msalOptions *MsalClientOptions,
) (string, int64, error) {
client, err := getPublicClient(msalOptions)
if err != nil {
return "", -1, err
}
popKey, err := GetSwPoPKey()
if err != nil {
return "", -1, err
}
result, err := client.AcquireTokenByUsernamePassword(
context,
scopes,
username,
password,
public.WithAuthenticationScheme(
&PoPAuthenticationScheme{
Host: popClaims["u"],
PoPKey: popKey,
},
),
public.WithTenantID(msalOptions.TenantID),
)
if err != nil {
return "", -1, fmt.Errorf("failed to create PoP token with username/password flow: %w", err)
}
return result.AccessToken, result.ExpiresOn.Unix(), nil
}