custom-components / sensor.trakt

📺 Trakt Integration for Upcoming Media Card
https://trakt.tv/
MIT License
61 stars 14 forks source link

Wrong redirect URL #69

Closed holantomas closed 5 months ago

holantomas commented 2 years ago

Version of Home Assistant

Home Assistant 2022.10.3

Version of the custom_component

2.0.4

Configuration

None. Over gui

Describe the bug

It's easy. I don't use HA Cloud but have public, static IP with domain. So I setup Trakt app with redirect_uri to https://my_domain_censored/auth/external/callback but if I try to add integration to HA it will redirect me to trakt page with error The requested redirect uri is malformed or doesn't match client redirect URI.. So I check request URL and there's wrong redirect_uri parameter. Instead of what I configured in Trakt app, HA sending:

https://api-v2launch.trakt.tv/oauth/authorize?response_type=code&client_id=CENSORED&redirect_uri=https://my.home-assistant.io/redirect/oauth&state=CENSORED

As you can see the redirect_uri param is send as https://my.home-assistant.io/... what is URL to Nabu Casa I guess. I don't find way to force integration to send actual URL.

And yes I tried Nabu Casa cause of Google Assistant, there can be problem, but now I'm logged of the cloud and don't know if HA keep this URL.

use-the-fork commented 2 years ago

The fix for this is to change your redirect url when setting up the API integration to: https://my.home-assistant.io/redirect/oauth

holantomas commented 2 years ago

@use-the-fork

OK but the doc is wrong

Use the following redirect_uri:
With HA cloud configured: https://<cloud-remote-url>/auth/external/callback
Without HA cloud configured: http://<local-ip>:/auth/external/callback
bcutter commented 1 year ago

Indeed,

  1. the docs are wrong
  2. the trick using https://my.home-assistant.io/redirect/oauth is working

Due to the recent database maintenance of Trakt.tv, possibly more users need to reauthenticate in the next days and will likely run into this issue too.