ThomasKur / M365Documentation

Automatic Microsoft 365 Documentation to simplify the life of admins and consultants.
Other
300 stars 45 forks source link

Client Secret Conversion Error #4

Closed hang10z closed 2 years ago

hang10z commented 3 years ago

Tried to use this command using my app values and tenant id: Connect-M365Doc -ClientId '00000000-0000-0000-0000-000000000000' -ClientSecret (ConvertTo-SecureString 'SuperSecretString' -AsPlainText -Force) -TenantId '00000000-0000-0000-0000-000000000000'

I get the following error:

Cannot process argument transformation on parameter 'ClientSecret'. Cannot convert the | "System.Security.SecureString" value of type "System.String" to type "System.Security.SecureString".

ThomasKur commented 3 years ago

Hmm strange on my side this is working. But do I assume correctly, that you had customized the command with your ClientID, TenantId and Secret?

Dirk-Manderin commented 3 years ago

I'm getting the same error message as hang10z. I have verified I'm using the correct ClientId, ClientSecret and TenantId for the application registration I created with New-M365DocAppRegistration. I'm using PowerShell 5.

Edit: I played around with it a bit and if I call Get-MsalToken directly and pass the parameters to it, I get a token back. (Literally just replace Connect-M365Doc with Get-MsalToken). It looks like you're converting ClientSecret to a regular string in the param section - [string]$ClientSecret. If I change that to [Security.SecureString]$ClientSecret, everything works.

ThomasKur commented 3 years ago

I have fixed this in the code. Will publish a new version soon.

ThomasKur commented 2 years ago

Fixed in actual published version