Sort out planet/sentinel oauth #118
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In #111 we added some basic integration with Planet. One of the things I'm trying to test in integration testing is that the credentials work for making requests to planet. For according to Planet's auth docs:
It seems like there's some serious breakage in Planet's OAuth setup after their aquisition of Sentinel. They are refactoring it, but after I log in there is a message indicating that they are "working on a new dashboard experience". They've removed the ability to create new OAuth client IDs and secrets for now.
What I'd like you to do for this issue is try to sort out how the planet Python SDK, which I think is available at https://github.com/sentinel-official/sentinel-python-sdk.git, handles their OAuth. Do they have a client ID and secret baked into the SDK? Do they download it from somewhere? If we can mimic what it does we might be able to continue testing while we wait for them to sort out their broken dashboard.
Hi diddly ho neighborino! I dug into the Planet Python SDK to sort out how they handle OAuth. Here is what I found:
The SDK
The actual Planet Python SDK lives at planetlabs/planet-client-python (not sentinel-official/sentinel-python-sdk, which is an unrelated blockchain project). The current version is 3.x, and it has been significantly re-architected to delegate auth to separate packages:
planet_authandplanet_auth_utils.Yes, They Have a Baked-In Client ID
In
auth_builtins.pythere is a hardcoded OAuth client ID:This is used as the default client ID for the built-in
"planet-user"profile. It is a public client (no secret) used with the OAuth2 Device Code flow (oidc_device_code). This is the same client shared by theplanetCLI. The CLI plumbed throughplanet_auth_utilsto handle the login flow, and it even monkey-patches the CLI to hide the client_id/client_secret options because the built-in defaults work for interactive login.Auth Server Endpoints
https://login.planet.com/(audience:https://api.planet.com/)https://services.sentinel-hub.com/auth/realms/main(audience:https://api.planet.com/)https://api.planet.com/v0/auth/loginWhat Is NOT Baked In
The M2M client credentials (
planet-m2mprofile) are not pre-configured. The skeleton config requires user-suppliedclient_idandclient_secret. There is a code comment that says:So the dashboard situation you observed is real — they have not finished the OAuth client registration UI.
What This Means for Testing
For integration testing, you have several options:
Option 1: Legacy API Key (simplest)
The legacy auth still works. If you have a Planet API key, you can set it in the environment:
PL_API_KEY(deprecated but still supported)PL_AUTH_API_KEY(new-style env var)Or pass it programmatically:
Auth.from_key("your-api-key")The legacy auth endpoint is
POST https://api.planet.com/v0/auth/loginand the response is a JWT bearer token.Option 2: Use the Baked-In OAuth Client (interactive)
In the Go test code, you could replicate the device code flow using the public client ID
49lHVBYlXCdfIYqE1B9zeXt0iFHSXeesagainsthttps://login.planet.com/— but this requires interactive user login (browser or TTY), which isn't ideal for automated integration tests.Option 3: M2M with Sentinel Hub M2M Credentials
If you have a Sentinel Hub (services.sentinel-hub.com) account, you may be able to create M2M client credentials there. The Planet SDK's M2M config points at Sentinel Hub's Keycloak realm, and the audience is
https://api.planet.com/. So existing Sentinel Hub M2M credentials might work with Planet's APIs. This would be worth testing if you have Sentinel Hub access.Option 4: Environment Variable Based Auto-Detection
Auth.from_user_default_session()checks, in priority order:PL_AUTH_CLIENT_ID+PL_AUTH_CLIENT_SECRET(OAuth2 M2M)PL_AUTH_API_KEY(legacy API key)PL_AUTH_PROFILE(saved profile)For Go integration testing, I would recommend supporting Option 1 (simple bearer token from API key) as the primary testing path, and optionally Option 3 (Sentinel Hub M2M) if you have those credentials. The go-planet library probably just needs to accept either an API key or OAuth token and pass it as an
Authorization: Bearer <token>header tohttps://api.planet.com/endpoints.