Skip to content

Provider.ExchangeOnline cant authenticate to bearerToken error #224

@blindzero

Description

@blindzero

Description

Whenever involving any ExchangeOnline provider capability, I get the error

Exception calling "EnsureMailboxType" with "3" argument(s): "Exception calling "GetMailbox" with "2" argument(s): "Exception
               calling "GetMailbox" with "2" argument(s): "Exception calling "InvokeSafely" with "2" argument(s): "The variable
               '$bearerTokenPattern' cannot be retrieved because it has not been set."""" 

Steps to Reproduce

  1. Create any ExchangeOnline Workflow step
  2. Create AuthSession with Scopes
$scopes = @(
  'User.ReadWrite.All'
  'Group.Read.All'
  'GroupMember.ReadWrite.All'
  'MailboxSettings.ReadWrite'
)

and

$entraToken = Get-MsalToken -TenantId $tenantId -ClientId $clientId -Scopes $scopes -DeviceCode`
$entraAccessToken = $entraToken.AccessToken

and using this accesstoken for Idle-AuthSessionBroker setup.

Expected Behavior

Authentication with token provided.

Actual Behavior

It brings the error.

Environment

  • PowerShell version: 7.5.4
  • OS: Windows Server 2019
  • IdLE version / commit: main

Additional Context

  • Same procedure works with Entra Provider, so assuming something provider specific. Maybe to adopt the authentication methods from AD Provider?
  • I was using the same $entraAccessToken variable for both provider AuthSessions:
$authSessions = New-IdleAuthSession -SessionMap @{
    @{ AuthSessionName = 'AD' }  = @{ AuthSessionType = 'Credential'; Credential = $adCred }
    @{ AuthSessionName = 'Entra' } = @{ AuthSessionType = 'OAuth'; Credential = $entraAccessToken }
    @{ AuthSessionName = 'EXO' } = @{ AuthSessionType = 'OAuth'; Credential = $entraAccessToken }
}
$providerAD = New-IdleADIdentityProvider
$providerEntra = New-IdleEntraIDIdentityProvider
$providerEXO = New-IdleExchangeOnlineProvider
$providers = @{
    AD = $providerAD
    Entra = $providerEntra
    EXO = $providerEXO
    AuthSessionBroker = $authSessions
}

But also duplicating the tokens to a separate $entraAccessToken and $exoAccessToken does not change the behavior.

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions