Authentication not provided error using access token (oauth)

After fetching auth token from using the below-mentioned process, we get the auth token, but when we try to POST using that token, it errors with ‘Authentication credentials were not provided’ message.


# SUCCESS RESPONSE WITH {'access_token': 'XXXXX', 'token_type': 'Bearer', 'expires_in': 36000, 'refresh_token': 'XXXXXXX', 'scope': 'read write'}
curl -X POST \
    -H "Accept: application/json" \
    -d "grant_type=authorization_code&client_id=${KOBO_TOOLBOX_CLIENT_ID}&redirect_uri=${KOBO_TOOLBOX_REDIRECT_URI}&code=${ACCESS_CODE}" \
    -u "${KOBO_TOOLBOX_CLIENT_ID}:${KOBO_TOOLBOX_CLIENT_SECRET}" | jq -r '.access_token'


# NOT WORKING: {"detail":"Authentication credentials were not provided."}
curl -X POST \
    -d 'asset_type=survey&name=Test' \
    -H "Accept: application/json" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}"

Could you share more details on the platform you are using to access or post with JSON. Give some more details on your conifguration to enable us best understand what exactly is causing the issue. Have you ever done this successfully before even on another project?


Hi, thanks for the quick response.

Right now we are just using curl to test out the request and response as shared on the snippet above.
We’ll however, perform these requests from python later on after we successfully know the requests are working.

This is the first time we are trying to integrate our system with Kobo. We’ve successfully integrated oauth with OSM and HID before.

Glad to know The system should work just as fine for your integration needs. We documented steps in the various support articles


@stephanealoo We are trying to use oauth2 so that we can request to kobotoolbox on behalf of the user.

Until now, we have no trouble retrieving the access_token from kobotoolbox. What we are struggling with is with its use. When we request to kobotoolbox, the response is giving error as mentioned by OP.

Could you help us understand why it’s not working or what changes we should make?
This is where we are using the access_token.

curl -X POST \
    -d 'asset_type=survey&name=Test' \
    -H "Accept: application/json" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}"

Hi @theayer56
Our developers noted that you made an error in your last code that you used

Authorization: Bearer ... but you should use Authorization: Token ... as shown in the article I had shared earlier



Hi, @stephanealoo. Thanks for the reply.

In the article you mentioned, the token is accessible from https://[kpi-url]/token/?format=json.

But our requirement is different from that process. We want to get access to the token using OAuth, so that the user only provides the credentials to your service ([kpi-url] as mentioned in the article) instead of our service.

As you mentioned to use the Token, we get {"detail":"Invalid token."} error when we use the token from oauth.

Could you provide documentation on how to use OAuth on kobo? We are using this tutorial so far, which doesn’t seem to be valid.