Skip to content

Commit 356b05e

Browse files
oauth via plauth lib for main 3.0 dev branch (#1121)
Initial merge of OAuth via the planet auth library for the SDK. This deeply changes the planet.Auth class and the CLI functions related to auth, but should be pretty light on the rest of the SDK.
1 parent b29af00 commit 356b05e

File tree

49 files changed

+2157
-677
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2157
-677
lines changed

.github/workflows/publish-pypi.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
restore-keys: |
2525
${{ runner.os }}-pip
2626
27-
- name: Build, verify, and upload to TestPyPI
27+
- name: Build, verify, and upload to PyPI
2828
run: |
2929
pip install --upgrade nox
3030
nox -s build publish_pypi

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ coverage.xml
2323
*.pyc
2424

2525
# Editors
26+
.idea/
2627
.vscode/
2728
# Docs build
2829
site
2930
.venv
31+
venv

docs/cli/cli-guide.md

+17-23
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ Yes. Even if you’re not writing code—and only using the "no code" CLI part o
3434
Install the Planet SDK for Python using [pip](https://pip.pypa.io):
3535

3636
```console
37-
$ pip install planet
37+
pip install planet
3838
```
3939

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

4242
```console
43-
$ planet --version
43+
planet --version
4444
```
4545

4646
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
5555

5656
### Authenticate with the Planet server
5757

58-
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.
58+
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.
5959

6060
At a terminal console, type the following Planet command:
6161

6262
```console
63-
$ planet auth init
63+
planet auth login
6464
```
6565

66-
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:
66+
A browser window should be opened, and you will be directed to login to your account. This
67+
command will wait for the browser login to complete, and should exit shortly afterwards.
68+
When this process succeeds, you will see the following message on the console:
6769

6870
```console
69-
Initialized
71+
Login succeeded.
7072
```
7173

72-
### Get your API key
73-
74-
Now that you’ve logged in, you can easily retrieve your API key that is being used for requests with the following command:
75-
74+
If you are in an environment where the `planet` command line utility cannot open a browser (such
75+
as a remote shell on a cloud service provider), use the following command and follow the instructions:
7676
```console
77-
planet auth value
77+
planet auth login --no-open-browser
7878
```
7979

80-
Many `planet` calls you make require an API key. This is a very convenient way to quickly grab your API key.
81-
82-
#### Your API Key as an Environment Variable
80+
### Get your Access Token
8381

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

8684
```console
87-
export PL_API_KEY=<your api key>
85+
planet auth print-access-token
8886
```
8987

90-
And you can see that the value was stored successfully as an environment variable with the following command:
91-
92-
```console
93-
echo $PL_API_KEY
94-
```
88+
Many `planet` calls you make require an access token. This is a very convenient way to quickly grab the current access token.
9589

96-
!!!note "The API Key environment variable is ignored by the CLI but used by the Python library"
97-
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`.
90+
**Note** : As a security measure, access tokens are time limited. They have a relatively short lifespan, and must
91+
be refreshed. The `print-access-token` command takes care of this transparently for the user.
9892

9993
## Step 5: Search for Planet Imagery
10094

docs/cli/cli-reference.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ title: CLI Reference
44

55
This page provides documentation for our command line tools.
66

7+
{% raw %}
78
::: mkdocs-click
89
:module: planet.cli.cli
910
:command: main
1011
:prog_name: planet
1112
:depth: 1
13+
{% endraw %}

docs/get-started/quick-start-guide.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ pip install planet
2727

2828
### Authentication
2929

30-
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).
30+
Use the `planet auth` CLI command to establish a user login session that will
31+
be saved to the user's home directory. For other authentication options, see
32+
the [Client Authentication Guide](../python/sdk-client-auth.md).
3133

3234
```bash
33-
export PL_API_KEY=your_api_key
35+
planet auth login
3436
```
3537

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

4042
```python
4143
from planet import Planet
42-
pl = Planet() # automatically detects PL_API_KEY
44+
pl = Planet() # automatically detects authentication configured by `planet auth login`
4345
```
4446

4547
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).

0 commit comments

Comments
 (0)