Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth2 support via planet_auth python libraries #1063

Open
wants to merge 91 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
bf662f0
ignore venv and pycharm files.
carl-adams-planet Jul 7, 2024
92fb28b
Work in progress.
carl-adams-planet Jul 8, 2024
03beb9f
working on using planet_auth library
carl-adams-planet Aug 25, 2024
25c2583
update requirements
carl-adams-planet Aug 26, 2024
971bac1
WIP
carl-adams-planet Aug 27, 2024
02c0562
WIP
carl-adams-planet Sep 3, 2024
a78f5ef
Merge branch 'main' into carl/oauth-via-plauth-lib
carl-adams-planet Sep 3, 2024
d4063b5
some better handling of options for the plauth lib
carl-adams-planet Sep 4, 2024
c7ed86c
more plauth lib work
carl-adams-planet Sep 4, 2024
a9ff294
update notes
carl-adams-planet Sep 4, 2024
7868a0f
fix setup
carl-adams-planet Oct 5, 2024
f5844d1
Merge branch 'main' into carl/oauth-via-plauth-lib
carl-adams-planet Oct 5, 2024
6b03579
Merge branch 'main' into carl/oauth-via-plauth-lib
carl-adams-planet Nov 25, 2024
40755ff
update to latest refactoring of auth libs
carl-adams-planet Nov 30, 2024
a9ddd35
update comments
carl-adams-planet Nov 30, 2024
c6d6e74
update comments
carl-adams-planet Nov 30, 2024
834d950
update comments
carl-adams-planet Nov 30, 2024
6085d70
fix env vars
carl-adams-planet Dec 4, 2024
947b103
fix builtins
carl-adams-planet Dec 5, 2024
f9ac787
let cli.py be run as a module
carl-adams-planet Dec 5, 2024
c4464f9
Merge branch 'main' into carl/oauth-via-plauth-lib
carl-adams-planet Dec 22, 2024
19f2a44
I don't think we need a profile literally named 'default'
carl-adams-planet Dec 22, 2024
f08cdd8
working on integration
carl-adams-planet Dec 31, 2024
2a96d01
holiday work
carl-adams-planet Jan 6, 2025
5ff942a
reviving auth command
carl-adams-planet Jan 10, 2025
7a5c10b
depend on dev repo
carl-adams-planet Jan 14, 2025
05c0eb3
Merge branch 'carl/oauth-via-plauth-lib' of github.com:planetlabs/pla…
carl-adams-planet Jan 14, 2025
ea16e9f
working on plauth integration planet auth cli
carl-adams-planet Jan 18, 2025
a0ea285
Merge branch 'main' into carl/oauth-via-plauth-lib
carl-adams-planet Jan 18, 2025
262db0c
formatting
carl-adams-planet Jan 18, 2025
179d449
yapf formatting
carl-adams-planet Jan 18, 2025
324a1c4
harmonize flak8 and yapf
carl-adams-planet Jan 18, 2025
441ecbf
ignore planet auth deprecation warnings.
carl-adams-planet Jan 21, 2025
fbf0f37
Make 'none' a valid built-in auth type
carl-adams-planet Jan 21, 2025
b9542ab
remove AuthSession from http.py
carl-adams-planet Jan 21, 2025
67fd3a2
add skel auth config
carl-adams-planet Jan 21, 2025
88fa6ac
update main Auth() API
carl-adams-planet Jan 21, 2025
3069baa
test updates
carl-adams-planet Jan 21, 2025
a12ca4c
update CLI guide with new login command
carl-adams-planet Jan 21, 2025
261e1fe
lint fixes
carl-adams-planet Jan 21, 2025
bc20fe9
yapf formatting
carl-adams-planet Jan 21, 2025
bdcc0be
linting fixes
carl-adams-planet Jan 22, 2025
b9f9084
disable cache for branch work.
carl-adams-planet Jan 22, 2025
d99d89b
WIP
carl-adams-planet Jan 22, 2025
20f26e7
no StrEnum in lowest supported Py version.
carl-adams-planet Jan 22, 2025
b5081b2
cleanup
carl-adams-planet Jan 22, 2025
c8350f7
implement suggestions from the team
carl-adams-planet Jan 27, 2025
158e29d
linting fixes
carl-adams-planet Jan 27, 2025
3c374ac
yapf antidepressants
carl-adams-planet Jan 27, 2025
3a08037
Merge branch 'main' into carl/oauth-via-plauth-lib
carl-adams-planet Feb 7, 2025
646324f
Initial auth examples
carl-adams-planet Feb 19, 2025
43cda55
linting and formatting
carl-adams-planet Feb 19, 2025
bc37b3d
formatting and linting
carl-adams-planet Feb 19, 2025
10e8e57
Minor renamings
carl-adams-planet Feb 19, 2025
b863948
improve example
carl-adams-planet Mar 4, 2025
28c5e3a
improve example
carl-adams-planet Mar 4, 2025
93a98d9
update example
carl-adams-planet Mar 4, 2025
f5ea87b
update example
carl-adams-planet Mar 4, 2025
5b5a41c
update example
carl-adams-planet Mar 4, 2025
4056c5e
update example
carl-adams-planet Mar 4, 2025
31606a2
example updates
carl-adams-planet Mar 4, 2025
99f1d0b
update example
carl-adams-planet Mar 4, 2025
9a6e500
examples using custom storage
carl-adams-planet Mar 5, 2025
78e0228
update docs and examples
carl-adams-planet Mar 5, 2025
c3b43c1
update auth.py
carl-adams-planet Mar 5, 2025
a082761
Merge branch 'main' into carl/oauth-via-plauth-lib--update-from-main
carl-adams-planet Mar 5, 2025
2593019
Merge branch 'carl/oauth-via-plauth-lib--update-from-main' into carl/…
carl-adams-planet Mar 5, 2025
04ab6bc
disable cache for dev
carl-adams-planet Mar 5, 2025
4b2bb54
re-enable pip cache
carl-adams-planet Mar 5, 2025
ca4e0db
fix pyproject.toml
carl-adams-planet Mar 5, 2025
e84fc2c
linting fixes
carl-adams-planet Mar 5, 2025
71479f6
linting
carl-adams-planet Mar 5, 2025
91486da
type hint fixes
carl-adams-planet Mar 5, 2025
c7f2730
update tests to use new auth constructor.
carl-adams-planet Mar 5, 2025
9dec595
linting
carl-adams-planet Mar 5, 2025
28e7857
adjust class relationships for AuthType
carl-adams-planet Mar 5, 2025
e1430fd
update tests
carl-adams-planet Mar 5, 2025
c053813
minor updates - kill dead code lines.
carl-adams-planet Mar 5, 2025
26d8737
improve test coverage
carl-adams-planet Mar 5, 2025
2c151d0
adjust hard failure level for code coverage
carl-adams-planet Mar 6, 2025
79f3b73
adjust logging
carl-adams-planet Mar 9, 2025
62e3ed1
use a published version
carl-adams-planet Mar 10, 2025
b60e1ff
lint fixes
carl-adams-planet Mar 10, 2025
eade4c6
minor updates
carl-adams-planet Mar 10, 2025
9a46005
fix typo
carl-adams-planet Mar 10, 2025
eded1e5
remove off-named file I had saved locally
carl-adams-planet Mar 11, 2025
2e1f4d9
update planet auth
carl-adams-planet Mar 19, 2025
c9defc8
update package version
carl-adams-planet Mar 19, 2025
1408f9f
Merge branch 'main' into carl/oauth-via-plauth-lib
carl-adams-planet Mar 27, 2025
2dab6e7
copy SKEL usage.
carl-adams-planet Mar 28, 2025
ad19709
Remove 'none' built-in profile
carl-adams-planet Mar 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ jobs:
restore-keys: |
${{ runner.os }}-pip

- name: Build, verify, and upload to TestPyPI
- name: Build, verify, and upload to PyPI
run: |
pip install --upgrade nox
nox -s build publish_pypi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -23,7 +23,9 @@ coverage.xml
*.pyc

# Editors
.idea/
.vscode/
# Docs build
site
.venv
venv
10 changes: 10 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Changelog moved to https://github.com/planetlabs/planet-client-python/releases

3.0.0 (Unreleased)
- Overhaul of planet.Auth AP interface to leverage the
[Planet Auth Utility Library](https://github.com/planetlabs/planet-auth-python)
and move preferred authentication mechanisms to OAuth2 over API keys.
See the Client Authentication Guide in the documentation for details and
examples.
- Overhaul of the `planet auth` CLI to support Auth infrastructure overhaul.
Of immediate note to uses is that `planet auth login` should be preferred
to `planet auth init` to initialize the CLI client for use.

2.13.0 (2024-12-18)
- Add Planet class (`from planet import Planet`)
- Planet is a client that uses sync methods. Users do not have
40 changes: 17 additions & 23 deletions docs/cli/cli-guide.md
Original file line number Diff line number Diff line change
@@ -34,13 +34,13 @@ Yes. Even if you’re not writing code—and only using the "no code" CLI part o
Install the Planet SDK for Python using [pip](https://pip.pypa.io):

```console
$ pip install planet
pip install planet
```

## Step 3: Check the Planet SDK for Python version

```console
$ planet --version
planet --version
```

You should be on some version 2 of the Planet SDK for Python.
@@ -55,46 +55,40 @@ To confirm your Planet account, or to get one if you don’t already have one, s

### Authenticate with the Planet server

Just as you log in when you browse to https://account.planet.com, you’ll want to sign on to your account so you have access to your account and orders.
Just as you log in when you browse to https://planet.com/account, you’ll want to sign on to your account so you have access to your account and orders.

At a terminal console, type the following Planet command:

```console
$ planet auth init
planet auth login
```

You’ll be prompted for the email and password you use to access [your account](https://account.planet.com). When you type in your password, you won’t see any indication that the characters are being accepted. But when you hit enter, you’ll know that you’ve succeeded because you’ll see on the command line:
A browser window should be opened, and you will be directed to login to your account. This
command will wait for the browser login to complete, and should exit shortly afterwards.
When this process succeeds, you will see the following message on the console:

```console
Initialized
Login succeeded.
```

### Get your API key

Now that you’ve logged in, you can easily retrieve your API key that is being used for requests with the following command:

If you are in an environment where the `planet` command line utility cannot open a browser (such
as a remote shell on a cloud service provider), use the following command and follow the instructions:
```console
planet auth value
planet auth login --no-open-browser
```

Many `planet` calls you make require an API key. This is a very convenient way to quickly grab your API key.

#### Your API Key as an Environment Variable
### Get your Access Token

You can also set the value of your API Key as an environment variable in your terminal at the command line:
Now that you’ve logged in, you can easily retrieve an Access Token that is being used for requests with the following command:

```console
export PL_API_KEY=<your api key>
planet auth print-access-token
```

And you can see that the value was stored successfully as an environment variable with the following command:

```console
echo $PL_API_KEY
```
Many `planet` calls you make require an access token. This is a very convenient way to quickly grab the current access token.

!!!note "The API Key environment variable is ignored by the CLI but used by the Python library"
If you do create a `PL_API_KEY` environment variable, the CLI will be unaffected but the Planet library will use this as the source for authorization instead of the value stored in `planet auth init`.
**Note** : As a security measure, access tokens are time limited. They have a relatively short lifespan, and must
be refreshed. The `print-access-token` command takes care of this transparently for the user.

## Step 5: Search for Planet Imagery

2 changes: 2 additions & 0 deletions docs/cli/cli-reference.md
Original file line number Diff line number Diff line change
@@ -4,8 +4,10 @@ title: CLI Reference

This page provides documentation for our command line tools.

{% raw %}
::: mkdocs-click
:module: planet.cli.cli
:command: main
:prog_name: planet
:depth: 1
{% endraw %}
8 changes: 5 additions & 3 deletions docs/get-started/quick-start-guide.md
Original file line number Diff line number Diff line change
@@ -27,10 +27,12 @@ pip install planet

### Authentication

Use the `PL_API_KEY` environment variable to authenticate with the Planet API. For other authentication options, see the [SDK guide](../python/sdk-guide.md).
Use the `planet auth` CLI command to establish a user login session that will
be saved to the user's home directory. For other authentication options, see
the [Client Authentication Guide](../python/sdk-client-auth.md).

```bash
export PL_API_KEY=your_api_key
planet auth login
```

### The Planet client
@@ -39,7 +41,7 @@ The `Planet` class is the main entry point for the Planet SDK. It provides acces

```python
from planet import Planet
pl = Planet() # automatically detects PL_API_KEY
pl = Planet() # automatically detects authentication configured by `planet auth login`
```

The Planet client has members `data`, `orders`, and `subscriptions`, which allow you to interact with the Data API, Orders API, and Subscriptions API. Usage examples for searching, ordering and creating subscriptions can be found in the [SDK guide](../python/sdk-guide.md).
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.