laravel-currency icon indicating copy to clipboard operation
laravel-currency copied to clipboard

Now API key is needed in exchangerate.host

Open asntcrz opened this issue 1 year ago • 15 comments

All calls now prompt the following error:

AmrShawky\Exceptions\RequestException { "success": false, "error": { "code": 101, "type": "missing_access_key", "info": "You have not supplied an API Access Key. [Required format: access_key=YOUR_ACCESS_KEY]" } }

Could it be possible to include an option to use an API key?

Thank you!

asntcrz avatar Sep 28 '23 00:09 asntcrz

Any news? Will you extend this package?

dbsrb avatar Sep 28 '23 07:09 dbsrb

Thanks for reporting this, yes I will extend the package please wait for a new release. meanwhile please use the withOptions method and add the api key as a query param https://docs.guzzlephp.org/en/stable/request-options.html#query

amrshawky avatar Sep 28 '23 10:09 amrshawky

Thanks bro! It seems that they have a problem on their side because every time I try to send a request with the basic plan I get the response "Access Restricted - Your current Subscription Plan does not support this API Function", and I try to send just a basic request which should be included in basic plan :)

dbsrb avatar Sep 28 '23 10:09 dbsrb

No worries, looks like there are a few plans and the higher the plan the more functions you get, nothing stay free forever right :D

https://exchangerate.host/product

amrshawky avatar Sep 28 '23 10:09 amrshawky

Thanks for reporting this, yes I will extend the package please wait for a new release. meanwhile please use the withOptions method and add the api key as a query param https://docs.guzzlephp.org/en/stable/request-options.html#query

Thanks for checking in so quick. Yeah, apparently their service has changed even their website is different, it is still free for 1K requests/month, but now an API key is needed: https://exchangerate.host/

About your workaround, I tried but it still gave me the same error, not sure if I'm missing something?

Currency::convert()->from('USD')->to('EUR')->amount(1)->withOptions(['query' => ['access_key' => env('CURRENCY_API_ID')]])->throw()->get();

image

Thank you for the package and support!

asntcrz avatar Sep 28 '23 10:09 asntcrz

Oh shot okay thanks, other options works no idea why the query doesn't, maybe you should call the api directly for now using Laravel HTTP client

Thank you for reporting again

amrshawky avatar Sep 28 '23 10:09 amrshawky

Probably this is not working for a trial version Screenshot 2023-09-28 172212

sapnabindal avatar Sep 28 '23 11:09 sapnabindal

Probably this is not working for a trial version Screenshot 2023-09-28 172212

Annoying I just purchased the basic plan and currency switching still doesn't work even though it is stated on the plan.

elliottcoe avatar Sep 28 '23 11:09 elliottcoe

@asntcrz just so you know.

I made it work with changing for the free version the end point to not be secured and use http instead of https.

In order for this to be fixed I believe you must add settings for both - api key and the endpoint it self.

Hope this helps.

chelev avatar Oct 02 '23 13:10 chelev

@asntcrz just so you know.

I made it work with changing for the free version the end point to not be secured and use http instead of https.

In order for this to be fixed I believe you must add settings for both - api key and the endpoint it self.

Hope this helps.

How/where exactly did you update the endpoint to use http instead of https?

bed-beard avatar Oct 05 '23 01:10 bed-beard

Probably this is not working for a trial version Screenshot 2023-09-28 172212

How are you passing the API key to get this error? When I try it just tells me I haven't even supplied an API key. Looks like for you it is seeing your API key but telling you that your plan doens't support the function.

bed-beard avatar Oct 05 '23 01:10 bed-beard

I needed a quick drop in replacement for the convert() function. Here is something thats working for me, very much a quick fix that uses a free conversion endpoint: https://gist.github.com/ClaraLeigh/7a325b8c12138167b8a3eb7e6976700a

ClaraLeigh avatar Oct 05 '23 01:10 ClaraLeigh

You can use this API to get all the exchange rates from a specific currency

https://open.er-api.com/v6/latest/USD

(change USD to the base you want)

MoEmam203 avatar Oct 05 '23 14:10 MoEmam203

@amrshawky Could you accept, or check the last pull request regarding this topic ?

thanks a lot!

dgillier avatar Oct 08 '23 14:10 dgillier

The tests in the PR https://github.com/amrshawky/currency/pull/3 are failing

It's easier guys to use Laravel Http client for now, I just don't have the time now, The package is not only for conversion and the provider seems to change a lot of things so I have to go through all of their docs.

amrshawky avatar Oct 09 '23 13:10 amrshawky