Skip to content
This repository has been archived by the owner on Aug 27, 2021. It is now read-only.

Error, the originating url does not seem to be a valid microsoft redirect #100

Closed
riddledaxis opened this issue Dec 27, 2020 · 1 comment

Comments

@riddledaxis
Copy link

riddledaxis commented Dec 27, 2020

I'm having a problem configuring this integration, I have installed it through HACS and it is version 2.1.8.

I am running HassOS 5.9, HA 2020.12.1 and Supervisor version 2020.12.7

My configuration is:

o365:
  client_secret: !secret o365_client_secret
  client_id: !secret o365_client_id 
  email_sensor:
    - name: inbox
      max_items: 5
      is_unread: True

I followed the instructions and had to change the config link as it was using the internal rather than the external URL.
When I click the amended link and select the account to sign in as on the Microsoft page, it seems to sign me into Microsoft but then I still get the error.

"Error, the originating url does not seem to be a valid microsoft redirect"

If I manually type the external URL (that is being used by my Azure app) into my browser (https://myurl/api/o365), I also get the above error.

I am running the NGINX Proxy Manager for my external access, but this works fine with redirecting Google, Alexa and other external connections. So I do not think this is the problem.

As I have seen older fixes for similar issues, I have added the base_url and api_password back into my config but nothing seems to be working.

My HA logs only show this:

2020-12-27 20:44:04 INFO (MainThread) [homeassistant.setup] Setting up o365
2020-12-27 20:44:04 WARNING (SyncWorker_7) [custom_components.o365.utils] Could not loacte token at .O365-token-cache/o365.token
2020-12-27 20:44:04 WARNING (SyncWorker_7) [custom_components.o365.utils] Could not loacte token at .O365-token-cache/o365.token
2020-12-27 20:44:04 INFO (SyncWorker_7) [custom_components.o365] no token; requesting authorization

I would really appreciate any help you can offer with resolving this issue.

@riddledaxis
Copy link
Author

So I fixed this issue

I deleted my azure app and then I recreated it making sure that it was under my personal account as per the image below:

app_registrations

I also made sure that the Allow Public Client Flows was enabled.
app_authentication

This allowed me to link my Microsoft account, but there was an issue with the token retrieval to HA which created a CSRF error. Weirdly Microsoft showed my account as connected to the Azure HA app, but it wasn't connected in HA.

[O365.connection] Unable to fetch auth token. Error: (mismatching_state) CSRF Warning! State not equal in request and response.

I fixed this by using the alternative auth-flow

Everything now seems to be working

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant