Skip to content

Commit a559bef

Browse files
authored
Merge pull request #216 from rstudio/env-docs
2 parents ea242bc + ecf65bd commit a559bef

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

pins/constructors.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,23 @@ def board_connect(
435435
436436
Examples
437437
--------
438-
Use a server URL or set the `CONNECT_SERVER` environt variable to connect:
438+
Pins will automatically look for the `CONNECT_SERVER` and `CONNECT_API_KEY` environment variables:
439439
440440
```python
441-
server_url = "https://connect.rstudioservices.com"
442-
board = board_connect(server_url)
441+
# where environment vars CONNECT_SERVER and CONNECT_API_KEY are set
442+
board = board_connect()
443+
```
444+
445+
Or use the `[dotenv](https://saurabh-kumar.com/python-dotenv/)` package to load other environment variable names from a `.env` file:
446+
447+
```python
448+
import os
449+
from dotenv import load_dotenv, find_dotenv
450+
load_dotenv(find_dotenv())
451+
452+
api_key = os.getenv("MY_API_KEY")
453+
server_url = os.getenv("MY_CONNECT_URL")
454+
board = board_connect(server_url=server_url, api_key=api_key)
443455
```
444456
445457
In order to read a public pin, use `board_url()` with the public pin URL:

0 commit comments

Comments
 (0)