SCRT-HQ / PSGSuite

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
https://psgsuite.io/
Apache License 2.0
235 stars 67 forks source link

New-GoogleService : Multiple ambiguous overloads found for "AuthorizeAsync" #312

Open sctib opened 4 years ago

sctib commented 4 years ago

After going through the initial setup I call Set-PSGSuiteConfig -ConfigName PSGSuite -SetAsDefaultConfig -P12KeyPath $null -ClientSecretsPath "C:\PSGsuite\vocal-facet-xxxxxxxxxxxxxxxx.json" -AppEmail "psgsuite@vocal-facet-xxxxxxxxxx.iam.gserviceaccount.com" -AdminEmail "xxx@xxxxxx.xx" -Domain "xxxxxx.xx" -Preference "Domain" -ServiceAccountClientID "xxxxxxxxxxxxxxxxxxxxxxxx"

It returns with no error

However, subsequent calls gives the error: (get-GSUser).CustomerId New-GoogleService : Multiple ambiguous overloads found for "AuthorizeAsync" and the argument count: "6". At C:\Program Files\WindowsPowerShell\Modules\PSGSuite\2.36.4\PSGSuite.psm1:27207 char:20

get-GSUser : You cannot call a method on a null-valued expression. At line:1 char:2

Environment (please complete the following information):

FISHMANPET commented 4 years ago

It might be beneficial for us to implement some parameter sets for Set-PSGSuiteConfig, if you're using a Client Secrets Path, you shouldn't specify a P12KeyPath parameter. Without looking at your configuration file, what I suspect is happening is that null value has been saved and then regurgitated into the running config in a way that isn't truly null. When constructing the New-GoogleService, it first checks for a P12Key, and if it finds one in the config it uses that, and if it doesn't find a P12Key it uses the Client Secrets. By specifying P12Key (even as $null) the code is trying to use the nonexistent P12Key instead of trying the ClientSecret you've specified.

Try creating a new config but leaving out P12KeyPath entirely when you create it.