siennathesane / cloudflare-sync

A nice to have, MIT-licensed tool for using Cloudflare as a dynamic DNS provider.
MIT License
268 stars 19 forks source link

Invalid format for Authorization header #11

Closed anoduck closed 9 months ago

anoduck commented 4 years ago

Really cool idea having dockerized a cloudflare dyndns client. I am not sure what is generating the bug. The full error is:

cannot get upstream records: error from makeRequest: HTTP status 400: content "{\"success\":false,\"errors\":[{\"code\":6003,\"message\":\"Invalid request headers\",\"error_chain\":[{\"code\":6111,\"message\":\"Invalid format for Authorization header\"}]}],\"messages\":[],\"result\":null}"

I was first running it with the wrong "ZONE_ID", but figured out that one. It mounts "production.json" in the right place and reads off of that. I have played around with the "name" in production.json, and it didn't affect this error message at all. It was the only variable I could foresee causing the bug to be thrown.

siennathesane commented 4 years ago

Thanks! I'm glad you like it.

Have you tried compiling it locally and running it to see if you get the same error? If it's an HTTP 400 error, there's not much I can realistically do about that, but I can take a look.

Also, if you can give me step-by-step instructions to reproduce the issue, I'll see if I can reproduce it.

anoduck commented 4 years ago

Ok, I will compile it locally and see what that does. By doing so, it will make debugging much easier. I will try to report back within the week.

siennathesane commented 4 years ago

Any luck on the repro steps?

anoduck commented 4 years ago

OK, compiled it outside of docker, ran it and received the following errors:

2019/12/16 23:00:44 cannot get upstream records: error from makeRequest: HTTP status 400: content "{\"success\":false,\"errors\":[{\"code\":6003,\"message\":\"Invalid request headers\",\"error_chain\":[{\"code\":6111,\"message\":\"Invalid format for Authorization header\"}]}],\"messages\":[],\"result\":null}"

Which appear to be exactly the same as before.

I compiled it with go version 1.13.4 for linux/amd64 on alpine linux edge. My production.json looks like so:

[
  {
    "type": "A",
    "name": "example.com",
    "proxied": false,
    "ttl": 120,
    "priority": 1
  }
]

I ran the app with the following flags:

./cloudflare-sync -api-token '$API_TOKEN' -zone-id '$ZONE_ID'

Both the api token and zone id were randomized identifiers retrieved from my cloudflare account.


When I ran the script using the -zone-name flag instead of the -zone-id flag I received a completely different error. Which was:

2019/12/16 23:13:49 error getting zoneId from zoneName: ListZonesContext command failed: error from makeRequest: HTTP status 400: content "{\"success\":false,\"errors\":[{\"code\":6003,\"message\":\"Invalid request headers\",\"error_chain\":[{\"code\":6111,\"message\":\"Invalid format for Authorization header\"}]}],\"messages\":[],\"result\":null}"

Both errors appear to be concerned with "Invalid request header" and "Invalid format for Authorization header". A probably cause might be my version of Go. Let me know if there is any other information I can provide you with. Running the script is not "mission critical", and is acceptable if the error cannot be reproduced.

siennathesane commented 4 years ago

@anoduck can you please test with the most recent builds and let me know if you have the same results? Thanks!

anoduck commented 4 years ago

Yerp! Will do...It is a good time to do so.