Fly GQL API addCertificate returns UNAUTHORIZED

Hi there,

I followed the official documentation to create certificate through API here.

But when I call this mutation:

mutation CreateCertificate {
  addCertificate(appId: "my-app-id", hostname: "my-domain.com") {
    certificate {
      isConfigured
    }
  }
}

with the required Authorization header containing a valid account token:

{
  "Authorization": "Bearer ..."
}

I have the following error:

{
  "data": {
    "addCertificate": null
  },
  "errors": [
    {
      "message": "Not authorized to manage this certificate.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "addCertificate"
      ],
      "extensions": {
        "code": "UNAUTHORIZED"
      }
    }
  ]
}

Note that I can make other mutations like:

mutation CheckCertificate {
  checkCertificate(
    input: { appId: "my-app-id", hostname: "existing-domain.tld" }
  ) {
    certificate {
      isConfigured
    }
  }
}

the answer is ok:

{
  "data": {
    "checkCertificate": {
      "certificate": {
        "isConfigured": true
      }
    }
  }
}

Do you have any idea to fix this issue?

Maybe it’s a Fly bug?

PS: you can try it yourself on official Fly playground.

Thanks for help!

OK, I’ve found the solution!

I had created the token in my Fly account as indicated in the documentation.

The token did appear in my app under the ‘Tokens’ menu, but apparently it didn’t have all the rights needed to manage the certificates.

I recreated a new token from the Fly interface > my app > Tokens.

It works as expected.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.