Skip to content

Log in without the need for the browser extension - #49

Draft
peternijssen wants to merge 5 commits into
arjenbos:mainfrom
ha-parcel-integrations:feature/login
Draft

Log in without the need for the browser extension#49
peternijssen wants to merge 5 commits into
arjenbos:mainfrom
ha-parcel-integrations:feature/login

Conversation

@peternijssen

@peternijssen peternijssen commented May 30, 2026

Copy link
Copy Markdown
Contributor

This merges #48 and #52 as well as presenting a new authentication flow, which does not require the browser extension.

More info can be found here, where I requested people to test it out:
https://community.home-assistant.io/t/postnl-and-dhl-nl-integration/112433/524

Closes #6 and might influence #43

peternijssen and others added 5 commits May 16, 2026 21:59
- Fix coordinator AttributeError: pass config entry to PostNLCoordinator
- Fix wrong base class: SensorEntity instead of Entity
- Fix None guard on coordinator.data in handle_coordinator_data
- Fix AttributeError on ClientError.status: guard with isinstance check
- Remove OAuth access token from debug log (security)
- Fix async_setup_entry return type annotation: True -> bool
- Fix misleading log message in async_unload_entry
- Add requests to manifest requirements
- Add SensorStateClass.MEASUREMENT to both sensors
- Add DeviceEntryType.SERVICE and configuration_url to DeviceInfo
- Replace old-style state/unit_of_measurement/icon properties with native_value and _attr_ class variables

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add auth.py: full PKCE + Janrain Capture login flow using aiohttp,
  token refresh, no browser redirect required
- Replace OAuth2FlowHandler with a plain ConfigFlow (username/password)
  and reauth confirm step
- Replace AsyncConfigEntryAuth OAuth2Session wrapper with direct token
  management from the config entry; raises ConfigEntryAuthFailed on
  auth failure to stop the retry loop
- Catch HomeAssistantError in coordinator and convert to UpdateFailed
- Add receiverTitle to GraphQL shipment fragment and Package struct
- Remove application_credentials dependency from manifest and delete
  application_credentials.py
- Add translations/en.json so config flow strings render in the UI
- Add docs/api/ with full reference for login, userinfo, GraphQL and
  Track & Trace endpoints

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
If the refresh token is missing or rejected, attempt a full re-login
using the stored credentials before triggering a reauth notification.
This silently recovers from expired or rotated refresh tokens without
requiring user intervention.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@peternijssen peternijssen changed the title Feature/login Log in without the need for the browser extension May 30, 2026
@RoboMagus

Copy link
Copy Markdown
Contributor

@peternijssen, This PR caught my attention as I'd love to see some auth-flow improvements myself.

I cannot speak on behalf of the maintainer of this component, but some feedback that may still be applicable here (and most definately for the other PR you've opened): Please keep PRs limited to only the singe feature you're adding and do not include other PRs that have not yet been merged.
What you're doing now makes stuff only more difficult to review.

@peternijssen

Copy link
Copy Markdown
Contributor Author

Unfortunately Several parts depend on each other. It's up to the maintainer so I will adjust accordingly once he let's me know how to continue.

@peternijssen
peternijssen marked this pull request as ready for review June 21, 2026 17:36
@arjenbos

Copy link
Copy Markdown
Owner

Unfortunately Several parts depend on each other. It's up to the maintainer so I will adjust accordingly once he let's me know how to continue.

I prefer smaller scoped MR, which can be linked to each other and review them in a sequence.

@arjenbos

Copy link
Copy Markdown
Owner

To be honest, I am not comfortable with bypassing the whole oauth2 flow from a user-perspective. Also, when something changes on PostNL's side, then the whole integration will break. I also don't like the browser extension, but maybe we can find another approach?

@peternijssen

peternijssen commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

I have no other ideas at this point. We could also skip the login proces for now and focus on retrieving other data, although I made a lot of large alterations, so PostNL aligns with DHL and DPD in sense of sensors and attributes.

@peternijssen
peternijssen marked this pull request as draft June 28, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add instructions on how to get the oauth url without the use of a browser extension

3 participants