Skip to content

Conversation

@tbarsballe
Copy link
Contributor

Updates the four SDK notebooks, changing:

if not auth.is_initialized():
    auth.user_login(allow_open_browser=False, allow_tty_prompt=True)

to

auth.ensure_initialized(allow_open_browser=False, allow_tty_prompt=True)

This is a new utility method added in SDK v3.2.0, which is functionally the same as the prior block, except it also checks to see if the refresh token is expired, and performs a new login if it is (this could happen if a user had previously logged in, and then not made any calls to the SDK for a while).

See also: planetlabs/planet-client-python#1200

@matthew-ballard
Copy link
Contributor

I tried this in colab, and it hung. so I interrupted, and it semes to be hung on the sleep.

[/usr/local/lib/python3.12/dist-packages/planet_auth/oidc/api_clients/token_api_client.py](https://localhost:8080/#) in _polling_checked_call(self, token_params, timeout, poll_interval, auth_enricher)
     95             now_time = time.time()
     96             if (now_time - start_time) < timeout:
---> 97                 time.sleep(poll_interval)
     98             else:
     99                 # We expect a expired_token error code, but the caller could

KeyboardInterrupt:

If this "checks to see if the refresh token is expired, and performs a new login if it is" - will that work in a notebook environment?

@tbarsballe
Copy link
Contributor Author

I tried this in colab, and it hung. so I interrupted, and it semes to be hung on the sleep.

[/usr/local/lib/python3.12/dist-packages/planet_auth/oidc/api_clients/token_api_client.py](https://localhost:8080/#) in _polling_checked_call(self, token_params, timeout, poll_interval, auth_enricher)
     95             now_time = time.time()
     96             if (now_time - start_time) < timeout:
---> 97                 time.sleep(poll_interval)
     98             else:
     99                 # We expect a expired_token error code, but the caller could

KeyboardInterrupt:

If this "checks to see if the refresh token is expired, and performs a new login if it is" - will that work in a notebook environment?

Interesting. I've tested it both as a local notebook, and in Docker, and those worked fine. I'm not sure why collab is having trouble.

@tbarsballe
Copy link
Contributor Author

@matthew-ballard I just tried it out myself in collab, and the login part worked fine for me. Did you click the auth link and click "Authorize"?

@matthew-ballard
Copy link
Contributor

ah you can disregard, it works. you are right, I just confirmed but did not authorized, I was logged into a temp trial account so I don't usually authorize 😄

Copy link
Contributor

@matthew-ballard matthew-ballard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only request would be to change the contributing guide auth snippet

Copy link

@carl-adams-planet carl-adams-planet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tbarsballe tbarsballe merged commit 93ff37e into planetlabs:master Oct 30, 2025
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.

3 participants