When you triple click the API key on the factorio.com "Your new API key has been created" screen and then ctrl+c, it gets a whitespace at the beginning and the end of the API key. Which then causes an invalid API key error.
There's a "copy to clipboard" button on that page too so it is my fault for sure but triple click copy is a habit and the selection looks correct without pasting the result to a cleartext box to verify it.
I'd recommend trimming the whitespaces off the API key when it is input, to avoid this easy user mistake.
I did a dumb and got confused for an hour or so.
When you triple click the API key on the factorio.com "Your new API key has been created" screen and then ctrl+c, it gets a whitespace at the beginning and the end of the API key. Which then causes an invalid API key error.
There's a "copy to clipboard" button on that page too so it is my fault for sure but triple click copy is a habit and the selection looks correct without pasting the result to a cleartext box to verify it.
I'd recommend trimming the whitespaces off the API key when it is input, to avoid this easy user mistake.