mandarons / ha-bouncie

Home Assistant custom integration for Bouncie.com - track your car stuff in Home Assistant
BSD 3-Clause "New" or "Revised" License
32 stars 4 forks source link

[BUG] #22

Closed theOrakle closed 1 year ago

theOrakle commented 1 year ago

Describe the bug Not able to add integration

2023-02-10 08:32:44.872 ERROR (MainThread) [custom_components.bouncie.const] 'NoneType' object is not subscriptable Traceback (most recent call last): File "/opt/homeassistant/config/custom_components/bouncie/config_flow.py", line 61, in async_step_user info = await validate_input(self.hass, user_input) File "/opt/homeassistant/config/custom_components/bouncie/config_flow.py", line 37, in validate_input result = await bouncie_client.get_access_token() File "/opt/homeassistant/3.10.8/lib/python3.10/site-packages/bounciepy/async_rest_api_client.py", line 85, in get_access_token self._set_access_token(access_token=data["access_token"]) TypeError: 'NoneType' object is not subscriptable 2023-02-10 08:32:44.875 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session 2023-02-10 08:32:44.878 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector

To Reproduce

  1. Add Integration
  2. Fill client_id (tried with and without "-"s)
  3. Fill client_secret (only one way to do this)
  4. Fill redirect_url (Using Home assistant Cloud - nabu casa URL)
  5. Fill authorization_code (from users/devices)

Expected behavior

Integration added

Screenshots image

Configuration Home Assistant 2023.2.3 Frontend 20230202.0 - latest Python 3.10.8

Additional context Not that I can think of

theOrakle commented 1 year ago

Wrote a quick script to test with my details and a get an access token responded.

import requests
import json

url = "https://auth.bouncie.com/oauth/token"
creds = {
    "client_id": "14671homeassistant",
    "client_secret": "9Y-Redacted-XG",
    "grant_type": "authorization_code",
    "code": "WD-Redacted-k3Yvn",
    "redirect_uri": "https://47-redacted4.ui.nabu.casa"
} 

try:
    req = requests.post(url,json=creds)
    results = req.json()
except:
    print('Troubles talking to the API')
print(json.dumps(results,indent=3))  
theOrakle commented 1 year ago

The trailing / in the url was killing it...