Skip to content

PowerDNS: Error when using limited API key #617

@joachimcarrein

Description

@joachimcarrein

Hi,

We have PowerDNS from an external partner and we received a limited api key, which only has access to 1 zone.

When we try to use it, we get the following error:

Invoke-RestMethod : {"msg":"Zone access not allowed"}

At C:\Program Files\WindowsPowerShell\Modules\Posh-acme\4.28.0\Plugins\PowerDNS.ps1:310 char:25
+ ...           $response = Invoke-RestMethod @queryParams @script:UseBasic
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

the inner exception is The remote server returned an error: (403) Forbidden.

I have worked around this by putting an extra catch and continue in the Find-Zone function (line 316):

# 403 probably means no zone direct access if zone doesn't exist
if (403 -eq $_.Exception.Response.StatusCode) {
    Continue
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions