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

Not able to connect with cloudflare API #4

Open ligol opened 5 years ago

ligol commented 5 years ago

When I put the Clouflare Api Key, I got that error

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}"

Any idea where it could come from?

siennathesane commented 5 years ago

I have no idea, sorry. Can you provide some steps on how you got your API key from Cloudflare? My API key has Zone edit permissions, that might be a cause? Howe old is your API key?

ligol commented 5 years ago

With this key, i got "cannot get upstream records: error from makeRequest: HTTP status 403: insufficient permissions"

Capture d’écran 2019-09-06 à 20 52 09
siennathesane commented 5 years ago

On your API key, if you click the dropdown box, there's a View Summary option, can you click it and verify it has this permission?

image

That's the permission my API key has, and it works for me. Maybe @jgrahamc can connect us with someone that can help if that's not the case. I'm not an expert in their permissions, sorry!

ligol commented 5 years ago

Yes it has that permission. Concerning the ZoneId, you found it in the web url while being on the dns tab of the cloudflare website right?

ligol commented 5 years ago

Okay, I found the issue, I'm sorry, my ZoneId was incorrect, I thought it was the key on the url but it seems not.

Maybe the documentation could be improved to tell where is the ZoneId located on cloudflare website. Or maybe the project could add the option to auto discover the ZoneId by calling the ZoneIDByName method.

I could make a PR for that if you want.

siennathesane commented 5 years ago

Or maybe the project could add the option to auto discover the ZoneId by calling the ZoneIDByName method.

Sure, if you want to make a PR for it, that'd be great. :)

yaazkal commented 5 years ago

Hi, I got the same issue. I've checked that the zone id is correct.

In some way the request is malformed as the HTTP 400 suggest.

siennathesane commented 4 years ago

So I made a massive update recently, and I'm also getting the HTTP 400 errors, but I'm not 100% sure why. I did some debugging but I didn't see anything that stood out. I'll keep an eye on it, but if you could try the most recent update, that'd be great. Thanks!