Thoride
Thoride
AArduino
Created by Thoride on 5/31/2025 in #coding-help
Accessing arduino cloud api via python giving error 405
i've got it to work via a normal request (using the requests package) so idk why it wont work via the iot stuff
5 replies
AArduino
Created by Thoride on 5/31/2025 in #coding-help
Accessing arduino cloud api via python giving error 405
like i said its literally the copy paste from the site
5 replies
AArduino
Created by Thoride on 5/31/2025 in #coding-help
Accessing arduino cloud api via python giving error 405
from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session

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

# Get your token

oauth_client = BackendApplicationClient(client_id="client_id")
token_url = "https://api2.arduino.cc/iot/v1/clients/token"

oauth = OAuth2Session(client=oauth_client)
token = oauth.fetch_token(
token_url=token_url,
client_id="client_id",
client_secret="client_secret",
include_client_id=True,
audience="https://api2.arduino.cc/iot",
)

# store access token in access_token variable
access_token = token.get("access_token")

# configure and instance the API client with our access_token

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

# as an example, interact with the properties API
api = iot.PropertiesV2Api(client)

try:
resp = api.properties_v2_list(thing_id)
print(resp)
except ApiException as e:
print("Got an exception: {}".format(e))
from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session

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

# Get your token

oauth_client = BackendApplicationClient(client_id="client_id")
token_url = "https://api2.arduino.cc/iot/v1/clients/token"

oauth = OAuth2Session(client=oauth_client)
token = oauth.fetch_token(
token_url=token_url,
client_id="client_id",
client_secret="client_secret",
include_client_id=True,
audience="https://api2.arduino.cc/iot",
)

# store access token in access_token variable
access_token = token.get("access_token")

# configure and instance the API client with our access_token

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

# as an example, interact with the properties API
api = iot.PropertiesV2Api(client)

try:
resp = api.properties_v2_list(thing_id)
print(resp)
except ApiException as e:
print("Got an exception: {}".format(e))
5 replies