diff --git a/HISTORY.rst b/HISTORY.rst index 97729197..f2b80732 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,6 +11,7 @@ PlatformIO 3.0 Your devices are always with you! * `PIO Account `__ for extra professional features from `PlatformIO Plus `__ + and ``PLATFORMIO_AUTH_TOKEN`` environment variable for CI systems * Inject system environment variables to configuration settings in `Project Configuration File "platformio.ini" `__ (`issue #792 `_) diff --git a/docs/envvars.rst b/docs/envvars.rst index 38be79d0..346ac163 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -21,6 +21,19 @@ will behave on a computer. *PlatformIO* handles variables which start with ``PLATFORMIO_`` prefix. They have the **HIGHEST PRIORITY**. +How to set environment variable? + +.. code-block:: bash + + # Windows + set VARIABLE_NAME=VALUE + + # Unix (bash, zsh) + export VARIABLE_NAME=VALUE + + # Unix (fish) + set -x VARIABLE_NAME VALUE + .. contents:: General @@ -38,6 +51,15 @@ PlatformIO uses it to disable prompts and progress bars. In other words, ``CI=true`` automatically setup :envvar:`PLATFORMIO_DISABLE_PROGRESSBAR` to ``true``. +.. envvar:: PLATFORMIO_AUTH_TOKEN + +Allows to specify Personal Authentication Token that could be used for +automatic login in to :ref:`cmd_account`. It is very useful for :ref:`ci` +systems and :ref:`pio_remote` operations where you are not able manually authorize. + +You can get own Personal Authentication Token using :ref:`cmd_account_token` +command. + .. envvar:: PLATFORMIO_FORCE_COLOR Force to output color ANSI-codes even if the output is a ``pipe`` (not a ``tty``). @@ -165,7 +187,6 @@ Allows to override setting :ref:`setting_enable_telemetry`. Allows to override setting :ref:`setting_force_verbose`. - .. envvar:: PLATFORMIO_SETTING_ENABLE_SSL Allows to override setting :ref:`setting_enable_ssl`. diff --git a/docs/userguide/account/cmd_login.rst b/docs/userguide/account/cmd_login.rst index edb4d7ba..d7bb1e6e 100644 --- a/docs/userguide/account/cmd_login.rst +++ b/docs/userguide/account/cmd_login.rst @@ -27,7 +27,9 @@ Usage Description ----------- -Log in to :ref:`cmd_account`. +Log in to :ref:`cmd_account`. If you are not able to provide authentication +credentials manually you can use :envvar:`PLATFORMIO_AUTH_TOKEN`. This is +very useful for :ref:`ci` systems and :ref:`pio_remote` operations . Options ~~~~~~~ diff --git a/docs/userguide/account/cmd_token.rst b/docs/userguide/account/cmd_token.rst new file mode 100644 index 00000000..84cf2c55 --- /dev/null +++ b/docs/userguide/account/cmd_token.rst @@ -0,0 +1,44 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +.. _cmd_account_token: + +platformio account token +=========================== + +.. contents:: + +Usage +----- + +.. code-block:: bash + + platformio account token + + +Description +----------- + +Get or regenerate Personal Authentication Token. It is very useful for :ref:`ci` +systems, :ref:`pio_remote` operations where you are not able manually authorize. + +PlatformIO handles Personal Authentication Token from environment variable +:envvar:`PLATFORMIO_AUTH_TOKEN`. + +Options +~~~~~~~ + +.. program:: platformio account token + +.. option:: + --regenerate + + If this option is specified a new authentication token will be generated. diff --git a/docs/userguide/account/index.rst b/docs/userguide/account/index.rst index d7d79b86..819cbb07 100644 --- a/docs/userguide/account/index.rst +++ b/docs/userguide/account/index.rst @@ -38,3 +38,4 @@ To print all available commands and options use: cmd_logout cmd_password cmd_register + cmd_token diff --git a/platformio/commands/account.py b/platformio/commands/account.py index eb4c923c..b45b7839 100644 --- a/platformio/commands/account.py +++ b/platformio/commands/account.py @@ -49,6 +49,12 @@ def account_password(): pioplus_call(sys.argv[1:]) +@cli.command("token", short_help="Get or regenerate Authentication Token") +@click.option("--regenerate", is_flag=True) +def account_token(**kwargs): + pioplus_call(sys.argv[1:]) + + @cli.command("forgot", short_help="Forgot password") @click.option("-u", "--username") def account_forgot(**kwargs):