treflehq / trefle-api

🍀 Trefle is a botanical JSON REST API for plants species, allowing you to search and query over all the registered species, and build the next gardening apps and farming robots.
https://trefle.io
GNU Affero General Public License v3.0
485 stars 51 forks source link

Client Side Token #17

Closed evanBurg closed 5 years ago

evanBurg commented 5 years ago

Describe the bug Attempting to get a client side token returns a 404

To Reproduce Navigate to https://trefle.io/api/auth/claim

Expected behavior A client side token an expiry are returned in order to make client side requests to the api

lambda2 commented 5 years ago

Hey Evan, are you sure you performed a "POST" request ? For example, with curl:

curl -i -X POST "https://trefle.io/api/auth/claim?token=YOUR-TOKEN&origin=your-website.rocks"

HTTP/2 200
server: nginx/1.14.0 (Ubuntu)
date: Tue, 14 May 2019 12:07:52 GMT
content-type: application/json; charset=utf-8

{"token":"eyJhbGciOiJIUzI1NiIsItR5cCI6IkpXVCJ9.eyJpcCI6WzQ4LDQ2LDQ4LDQ2LDQ4LDQ2LDQ4XSwiaXNzdWVyX2lkIjoxLCJvcmlnaW4iOiJsYWdhLmNvIiwiYXVkIjoiSm9rZW4iLCJleHAiOjE1NTc4NDI3NjYsImlhdCI3MTU1NzgzNTU2NiwiaXNzIjoiSm9rZW4iLCJqdGkiOiIybWY4bWNjdjc2bWZwdmd2M2swMnR0bDEiLCJuYmYiOjE1NTc8MzU1NjZ9.TJYar9UhYm0TvMSIr_OPZdrXeOuQCiM7XYlmJ2S_9tM","expiration":1557842766}%
evanBurg commented 5 years ago

Totally my bad, I assumed it was a GET request. I am able to receive a token now, thanks so much for the fast reply.

FelixEder commented 4 years ago

@lambda2 Hi! I've been getting 500 Internal Server Error when trying to get my client side token through curl. I tried your exact same curl command as in your previous reply, but it still I get a 500. If I change the token I get an error about using an invalid token and if I remove the origin-param I get a 400 instead (but the body still says "Internal Server Error" :P ).

I'm really confused to what the problem might be, my website is https://goodseeds.web.app but that doesn't work either.

lambda2 commented 4 years ago

Hey @FelixEder, fixed now. Thanks for the feedback and sorry for the inconvenience 🙏

FelixEder commented 4 years ago

@lambda2 Awesome, thanks a lot! :D