Consume Rest API with Yii2

Hello,

I want to access and consume a REST API; I got from the provider: OAuth Key, Access Token and user + pass.

All the docs I found are related to how to create an API but nothing (I think) about how to connect, consume etc.

Can someone point me to the right direction?

Thanks!

I think you need to make requests using

Thanks for your answer!

I found this extension, could be the right one?

https://www.yiiframework.com/extension/yiisoft/yii2-authclient/doc/guide/2.2/en

Yes an no. It is for authentication via OAuth (client one with browser confirmation) and it may call API after authenticated but it depends on if you need server-side auth or not.

This is my first time creating an API client :see_no_evil:

I read the provider docs and looks like I need to use his OpenID Connect access, for what I read in that link I think the extension I mention in my previous message is perfect for it.

Can you take a fast look and just confirm that? Thanks a lot!

It’s not clear from the documentation what you will need to do because there are a number of options. You may need to use OpenID Connect, or just OpenID, or perhaps you don’t need either and can just use a developer API key. So you need to research your use of Spark some more to find your technical requirements.

Yes, you are right, I talked with my client, he will call Spark support, when he have an answer I’ll post here.

Hi,
Sorry for delay but I just get the answer from the client, Spark confirm: I need to use Access Token Authentication method.

Now Im confuse about it, looks like with the yii2-httpclient is enough? @samdark Can you confirm it? or if someone have another idea I really appreciated the help.

Hello,

any help with my question?

We have no experience with Spark so can’t confirm it.