async def request(ace_session, url): client = HTTPClient(client_id = CLIENT_ID, client_secret = CLIENT_SECRET ) await client.upload_access_token(session = ace_session, rs_url = url, endpoint = '/authz-info')
async def request_events(ace_session, url): client = HTTPClient(client_id = CLIENT_ID, client_secret = CLIENT_SECRET ) events_response = await client.access_resource(session = ace_session, rs_url = url, endpoint = '/events') return multi_loads(events_response)
async def request(): client = HTTPClient(client_id = CLIENT_ID, client_secret = CLIENT_SECRET ) ace_session = await client.request_access_token(as_url = AS_URL, audience = AUDIENCE, scopes = SCOPES ) return ace_session
async def request(ace_session, url): client = HTTPClient(client_id = CLIENT_ID, client_secret = CLIENT_SECRET ) data = cbor2.dumps({bytes(action.name, 'utf-8'): {'input': action.input}}) response = await client.post_resource(session = ace_session, rs_url = url, endpoint = '/actions/' + action.name, data = data) return response
async def request(ace_session, url): # TODO client = HTTPClient(client_id = CLIENT_ID, client_secret = CLIENT_SECRET ) data = cbor2.dumps({bytes(property_name, 'utf-8'): value}) response = await client.post_resource(session = ace_session, rs_url = url, endpoint = '/properties/' + property_name, data = data) return response
async def initialize(): client = HTTPClient(client_id=CLIENT_ID, client_secret=CLIENT_SECRET) # Request access token ace_session = await client.request_access_token(as_url=PC_AS_URL, audience=AUDIENCE, scopes=SCOPES) # Upload `token` to RS. # Returns `status=201` and `body=None`. # For more details, see `ace_custom.client.http_client.HTTPClient()`. await client.upload_access_token(session=ace_session, rs_url=RS_URL, endpoint='/authz-info') print(GREEN + 'POST /authz-info -> DONE.' + ENDC) return (client, ace_session)
async def main(): client = HTTPClient( client_id='ace_client_1', client_secret=b'ace_client_1_secret_123456' ) # Request access token session = await client.request_access_token( as_url=AS_URL, audience="tempSensor0", scopes=["read_temperature", "post_led"] ) # Upload token to RS await client.upload_access_token(session, RS_URL, '/authz-info') # Access temperature resource response = await client.access_resource(session, RS_URL, '/temperature') print(f"Response: {response}") # Update LED resource on RS data = { b'led_value': 1 } response = await client.post_resource(session, RS_URL, '/led', dumps(data)) print(f"Response: {response}")