pub fn get_auth_from_env_or_prompt() -> Authorization
Expand description

Get an Authorization instance from environment variables DBX_CLIENT_ID and DBX_OAUTH (containing a refresh token) or DBX_OAUTH_TOKEN (containing a legacy long-lived token).

If environment variables are not set, and stdin is a terminal, prompt interactively for authorization.

If environment variables are not set, and stdin is not a terminal, panics.

This is a helper function intended only for tests and example code. Use in production code is strongly discouraged; you should write something more customized to your needs instead.

In particular, in real production code, you probably don’t want to use environment variables. The client ID should be a hard-coded constant, or specified in configuration somewhere. It is not something that will change often, or maybe ever. The refresh token should only be stored somewhere safe like a file or database with restricted access permissions.