arduino / iot-client-py

Python client for Arduino IoT API
https://www.arduino.cc/reference/en/iot/api/
Other
23 stars 12 forks source link

Problems with openapi_client #40

Closed gregorymurad closed 4 years ago

gregorymurad commented 4 years ago

Hi,

I have an Arduino API properly set, I am able to get my access token correctly, but when I try to call method thingsV2List, for example, I can't seem to import openapi_client. I have installed arduino-iot-client and requests-oauthlib already.

Could you please help me figure out this issue?

Thank you.

Best,

Greg

luigigubello commented 4 years ago

Hi @gregorymurad

Generate an Oauth Token using your API client_id and secret_id, then try this code and give me a feedback

import iot_api_client as iot
from iot_api_client.rest import ApiException
from iot_api_client.configuration import Configuration

from pprint import pprint

client_config = Configuration(host="https://api2.arduino.cc/iot")
client_config.access_token = "YOUR_OAUTH_TOKEN"
client = iot.ApiClient(client_config)

# create an instance of the API class
api_instance = iot.ThingsV2Api(client)

try:
    # list things_v2
    api_response = api_instance.things_v2_list()
    pprint(api_response)
except ApiException as e:
    print("Exception when calling ThingsV2Api->thingsV2List: %s\n" % e)

Thank you! Best regards, Luigi

gregorymurad commented 4 years ago

Hi @luigigubello,

Thank you very much. It worked just fine. I recently purchased a MKR ENV shield and I am trying to get the data and display using Streamlit.

Have a great one!

Best,

Greg