Skip to content

Unable to access the Codeberg API via token #78

@manuelprinz

Description

@manuelprinz

Hey, thank you for developing this provider!

I am not sure if this is a "me" issue or not, so I am posting it here because I did not see any other way to ask a question.

I tried to obtain user information (and later create a repository) on https://codeberg.org, running Forgejo (version "13.0.0-dev-651-a48dce80+gitea-1.22.0", according to https://codeberg.org/api/v1/version). My configuration looks like this:

terraform {
  required_providers {
    forgejo = {
      source  = "svalabs/forgejo"
      version = "~> 0.5.0"
    }
  }
}

provider "forgejo" {
  host = "https://codeberg.org"
}

data "forgejo_user" "me" {
  login = "<<my username here>>"
}

The token is stored in the FORGEJO_API_TOKEN environment variable as documented, which is also exported. init works fine, but plan fails with the following error message:

Planning failed. OpenTofu encountered an error while generating this plan.

│ Error: Unable to Create Forgejo API Client
│ 
│   with provider["registry.opentofu.org/svalabs/forgejo"],
│   on codeberg.tf line 1, in provider "forgejo":
│    1: provider "forgejo" {
│ 
│ An unexpected error occurred when creating the Forgejo API client. If the error is not
│ clear, please contact the provider developers.
│ 
│ Forgejo Client Error: Get "https://codeberg.org/api/v1/version": net/http: invalid header
│ field value for "Authorization"

I tested it with the latest versions of OpenTofu and HashiCorp Terraform; both pick up version 0.5.4 of the provider, and show the same error message. Modifying the example to use a var and using the api_token key leads to the same result. Testing with username/password did not work due to 2FA.

I am not sure if this is an issue with my configuration, or a problem with the provider. Any help is appreciated!

I am happy to provide any debug information needed. (I cannot contribute, unfortunately, because I do not know Go. Beyond the very basics, at least.)

P.S.: It was also a surprise to see that the provider is from SVA. I've worked with SVA in the past and really enjoyed the experience!

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingquestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions