Ceerbeerus / beerbolaget

Gives you information about the latest beer available at Systembolaget in Sweden, also known as "Tillfälligt sortiment".
MIT License
4 stars 0 forks source link

Testing the auth-flow integrated release 0.4.0 - almost a susses #11

Closed JonasStenmarck closed 2 years ago

JonasStenmarck commented 4 years ago

Changed config according to the readme. Did get the configurator notification. Klicked the link for authorization of the app (Untapped site). Worked fine. Ended upp with a request in a new browser window with my callback URL and session token (URL?code=nnnnnnnnnnnnnnnnnn...).

Went back to the ha page and clicked the "I AUTHORIZED SUCCESSFULLY" button. Nothing happened. When reloading the ha page one more configurator notification appears.

Noticed a difference from the example: my callback (ha site) use https, don't know that matters.

Ceerbeerus commented 4 years ago

Can you paste your configuration.yaml? Is there any .untappd-token-cache file present in your folder? Anything in the log?

4 maj 2020 kl. 22:06 skrev JonasStenmarck notifications@github.com:

 Changed config according to the readme. Did get the configurator notification. Klicked the link for authorization of the app (Untapped site). Worked fine. Ended upp with a request in a new browser window with my callback URL and session token (URL?code=nnnnnnnnnnnnnnnnnn...).

Went back to the ha page and clicked the "I AUTHORIZED SUCCESSFULLY" button. Nothing happened. When reloading the ha page one more configurator notification appears.

Noticed a difference from the example: my callback (ha site) use https, don't know that matters.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

JonasStenmarck commented 4 years ago

configuration.yaml:

beerbolaget: api_key: !secret systembolaget_api image_url: "https://www.systembolaget.se/api/productsearch/search/sok-dryck" store: "PK-Huset" untappd_client_id: !secret untappd_client untappd_secret: !secret untappd_secret untappd_callback: https://ha.NNNNN.com/api/untappd

No .untappd-token-cache and nothing in the log.

Tried from different browser, same thing

Ceerbeerus commented 4 years ago

Does the callback URL in the browser match your URL for HA. i.e. the new browser window is showing your HA webgui?

JonasStenmarck commented 4 years ago

Yes it matches, but no html is generated only a blank page: https://ha.NNNNN.com/api/untappd?code=4B654AA3ANNNNNNNNNNNNNNNNN

Could I use the code for testing in some way? like generate the .untappd-token-cache file.

Ceerbeerus commented 4 years ago

Could you try updating to 0.4.4 and check the log?

Does HA have correct permission to be able to write to the config folder?

JonasStenmarck commented 4 years ago

Sure hang on!

JonasStenmarck commented 4 years ago

Now i get something in the log: 2020-05-05 22:31:43 ERROR (SyncWorker_12) [custom_components.beerbolaget] Error caching token.

The user that runs HA owns the config dir and has write rights

Ceerbeerus commented 4 years ago

That error message indicates either, that HA can’t write the file to your folder or that untappd doesn’t respond to your request with the token.

Naesstrom commented 4 years ago

I'm also having a problem with the config-flow. When I click the link I get a error message: {"meta":{"http_code":500,"error_type":"param_error","error_detail":"Your redirect_url is invalid or doesn't match what was provided in registration"},"response":[]} and the URL shown is: https://untappd.com/oauth/authenticate/?client_id=748A65063998C3477B76CDAAA168E7729628F166&response_type=code&redirect_url=https%3A%2F%2Fdomain.duckdns.org%3A8123%2Fapi%2Funtappd

Config looks like this:

beerbolaget:
  api_key: !secret systembolaget
  image_url: "https://www.systembolaget.se/api/productsearch/search/sok-dryck"
  store: "Samarkand"
  untappd_client_id: !secret untappd_ID
  untappd_secret: !secret untappd_Secret
#  untappd_token: !secret untappd_Token
  untappd_callback: !secret untappd_callback

and secret callback url is: untappd_callback: https://domain.duckdns.org:8123/api/untappd

Ceerbeerus commented 4 years ago

How does the callback URL look that you have provided to untappd when you got the api key?

The error message is from untappd and says it doesn’t match.

8 maj 2020 kl. 14:33 skrev Erik Näsström notifications@github.com:

 I'm also having a problem with the config-flow. When I click the link I get a error message: {"meta":{"http_code":500,"error_type":"param_error","error_detail":"Your redirect_url is invalid or doesn't match what was provided in registration"},"response":[]} and the URL shown is: https://untappd.com/oauth/authenticate/?client_id=748A65063998C3477B76CDAAA168E7729628F166&response_type=code&redirect_url=https%3A%2F%2Fdomain.duckdns.org%3A8123%2Fapi%2Funtappd

Config looks like this:

beerbolaget: api_key: !secret systembolaget image_url: "https://www.systembolaget.se/api/productsearch/search/sok-dryck" store: "Samarkand" untappd_client_id: !secret untappd_ID untappd_secret: !secret untappd_Secret

untappd_token: !secret untappd_Token

untappd_callback: !secret untappd_callback and secret callback url is: untappd_callback: https://domain.duckdns.org:8123/api/untappd

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

Naesstrom commented 4 years ago

Ah my bad, I used the old url without the api/untappd part, works fine now I think!

JonasStenmarck commented 4 years ago

Sorry for not following up last time - struggled until I fell asleep :) Untappd responds after klickning the authentication link with the URL: https://ha.stenmarck.com/api/untappd?code=3F4BD7F0A3742XXXXXXXXXXXXXXX as soon as the URL is loaded in a browser or even if copied and used with curl I get the same log entry as before: 2020-05-08 15:55:27 ERROR (SyncWorker_8) [custom_components.beerbolaget] Error caching token. So I believe that the file cant be written. Don't get it I think it has all rights it can have. we are talking about the .untappd-token-cache right?

Can I create the file myself from the URL reponse, just for trying if it works?

Ceerbeerus commented 4 years ago

Yea, it’s the .untappd-token-cache file. If the file doesn’t contain the token it will try to overwrite it with a token, i.e without correct permissions it will fail.

Try to give all users permission to write in the config folder temporary just to check if that works.

8 maj 2020 kl. 16:03 skrev JonasStenmarck notifications@github.com:

 Sorry for not following up last time - struggled until I fell asleep :) Untappd responds after klickning the authentication link with the URL: https://ha.stenmarck.com/api/untappd?code=3F4BD7F0A3742XXXXXXXXXXXXXXX as soon as the URL is loaded in a browser or even if copied and used with curl I get the same log entry as before: 2020-05-08 15:55:27 ERROR (SyncWorker_8) [custom_components.beerbolaget] Error caching token. So I believe that the file cant be written. Don't get it I think it has all rights it can have. we are talking about the .untappd-token-cache right?

Can I create the file myself from the URL reponse, just for trying if it works?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

JonasStenmarck commented 4 years ago

I sure tried to give 777 to the config folder. Also tried to generate an empty .untappd-token-cache file with 777 rights - same thing. I don't get it. Its like its not trying.

What should be wiritten?

Ceerbeerus commented 4 years ago

How does your setup look?

Hassio? Docker? Proxy?

8 maj 2020 kl. 17:32 skrev JonasStenmarck notifications@github.com:

 I sure tried to give 777 to the config folder. Also tried to generate an empty .untappd-token-cache file with 777 rights - same thing. I don't get it. Its like its not trying.

What should be wiritten?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

JonasStenmarck commented 4 years ago

hassbian (on Linux) nginx proyx (running in a docker)

And maybe there is the answer - maybe have to fiddle with the cgi folder config in nginx. but it sure does some thing... I could try changing the URL and run it directly to the ha host.

Ceerbeerus commented 4 years ago

I have something you could try first. I’ve sent you a message on fb, i think.

8 maj 2020 kl. 17:59 skrev JonasStenmarck notifications@github.com:

 hassbian (on Linux) nginx proyx (running in a docker)

And maybe there is the answer - maybe have to fiddle with the cig folder config in nginx. but it sure does some thing... I could try changing the URL and run it directly to the ha host.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.