kobotoolbox / kpi

kpi is the (frontend) server for KoboToolbox. It includes an API for users to access data and manage their forms, question library, sharing settings, create reports, and export data.
https://www.kobotoolbox.org
GNU Affero General Public License v3.0
132 stars 179 forks source link

Problem getting authentication token #1371

Open adilyalcin opened 7 years ago

adilyalcin commented 7 years ago

Hi,

I am having issues with setting up oAuth based authentication with Kobo (on humanitarianresponse server), at the "Request for access token" step.

After I get the code back from Kobo authorization page, I try to send the request as in the documentation, but it returns {"error": "invalid_grant"} error.

Here is how my request looks like in CURL. I replace specific request values with all caps.

curl -X POST -d "grant_type=authorization_code&code=CODE&client_id=CLIENT_ID&redirect_uri=URL" "https://kc.humanitarianresponse.info/o/token/" --user "CLIENT_ID:SECRET"

At Kobo registered application, the settings are also as suggested. Client type: confidential Authorization Grant Type: authorization-code

What can be the issue here? I'd appreciate a quick reply since we need to have a functional deployment soon.

Thank you,

adilyalcin commented 7 years ago

I could eventually fix the errors after I changed client_type in app registration

In https://kc.humanitarianresponse.info/api/v1/ , the strongly suggested client type was confidential. It doesn't work on my part. Public works.

It would be nice if the developers here can check out the setting and update the documentation if necessary.

Thanks,