Error 401 "Authentication credentials were not provided"when upload model


(4535993) #1

Hi, i'm trying to upload a model with my javascript code, but after get my access token with the oauth 2.0 mechanism, i'm have in response from the post the response Error 401
with text.

  "detail": "Authentication credentials were not provided."

even with the swagger ui example "Swagger Ui Post Models" i'm still don't understand what are these credentials i forgot to put on the post



You need to add an authorization header with your API Token.

beforeSend: function ( xhr ) {
    xhr.setRequestHeader('Authorization', 'Token ' + API_TOKEN );

(4535993) #3

Hello Sorry I'm late, the mistake maybe is not due to SketchFab but to the Swagger API I use to authenticate with SketchFab. Although the documentation is written that supports both the "Token" and "Bearer" (like your suggestion) authorization for some reason unknown to me authentication "Token" failed always returning the error "401 Credentials not authorized" I have not delved into why it behaves this way, I simply decided to use "Bearer" and now it's work fine. if anyone know the reason of this i'm will very happy to understand why. Just a premise i use Swagger APIKeyAuthorization for set the Authorization header, so maybe the same thing with other javascript code can work with that.


Sometimes it (incorrectly) throws an authentication error when it's really an error with the JSON you sent. I can't say for sure without seeing your full script