Giter Site home page Giter Site logo

Comments (12)

nbogojevic avatar nbogojevic commented on June 18, 2024 1

II think that one is used for getting health data.

Authorization code still uses old one:

URL: Final = "https://account.withings.com"
PATH_AUTHORIZE: Final = "oauth2_user/authorize2"
PATH_TOKEN: Final = "oauth2/token" # nosec

And it is used in

def get_credentials(self, code: str) -> Credentials2:
"""Get the oauth credentials."""
response: Final = self._session.fetch_token(
"%s/%s" % (self.URL, self.PATH_TOKEN),
code=code,

self._client: Final = OAuth2Session(
self._credentials.client_id,
token=token,
client=WebApplicationClient( # nosec
self._credentials.client_id,
token=token,
default_token_placement="query",
),
auto_refresh_url="%s/%s" % (WithingsAuth.URL, WithingsAuth.PATH_TOKEN),

Also request output changed, so this:


and this
self._update_token(token=token_dict)

should probably be
**response["body"],
and
self._update_token(token=token_dict["body"]) ,

I did those changes in my fork https://github.com/nbogojevic/python_withings_api/, going to check tomorrow if that fixes the issue.

from python_withings_api.

mkaatman avatar mkaatman commented on June 18, 2024

It looks like it is already pointing at the new oauth endpoint.

https://github.com/vangorra/python_withings_api/blob/master/withings_api/__init__.py#L60

from python_withings_api.

mkaatman avatar mkaatman commented on June 18, 2024

Oh you're correct. Good catch.

from python_withings_api.

mkaatman avatar mkaatman commented on June 18, 2024

How'd that work out?

from python_withings_api.

nbogojevic avatar nbogojevic commented on June 18, 2024

Not complete success. Starts correctly, but refresh fails. Now there are two different URLs one for refresh (wsbapi) and the old one for authentication https://account.withings.com. And it seems that the something is changed in payloads. I'd need to debug little bit more to see what is actually going on during oauth2 flow.

from python_withings_api.

Madj42 avatar Madj42 commented on June 18, 2024

If you guys need another tester, I'd be willing to have a go. Unfortunately I haven't had the time to dedicate to adding python to my list of languages so I can't help there.

from python_withings_api.

Madj42 avatar Madj42 commented on June 18, 2024

BTW, the PR below and it's commits were never put in. Vangorra had a bunch of changes to workaround some other bugs and the reauth bug supposedly.

home-assistant/core#39684

from python_withings_api.

nbogojevic avatar nbogojevic commented on June 18, 2024

I've created PR #76 with token refresh fix, tested in Home Assistant. I'm running long time test to see if updates are affected.

from python_withings_api.

Madj42 avatar Madj42 commented on June 18, 2024

Can we run this though on our system without having to have it pull the API from pypi or wherever it pulls from?

from python_withings_api.

nbogojevic avatar nbogojevic commented on June 18, 2024

Might be complicated. I patched the library directly into home assistant.
If you can log in to shell of your Home Assistant container, then you could do following:

cd /usr/local/lib/python3.9/site-packages/withings_api
curl https://raw.githubusercontent.com/nbogojevic/python_withings_api/master/withings_api/__init__.py

And then restart HA.

from python_withings_api.

nbogojevic avatar nbogojevic commented on June 18, 2024

For info there probably needs to be another fix for Home Assistant component, but for the time being I don't have issue.

https://github.com/home-assistant/core/blob/b3cda6b6814703387e449068e8088f5b83880600/homeassistant/components/withings/__init__.py#L86-L87

from python_withings_api.

nbogojevic avatar nbogojevic commented on June 18, 2024

Created new pull request as #78 as changes in Withings response are not compatible with default behavior of requests_oauthlib and oauthlib and are breaking reauth flows.

from python_withings_api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.