Skip to content

Commit fc4e71b

Browse files
authored
Release 0.1.2 - Add Advance Options to REAME.md (#21)
* Add Advance Options to REAME.md * Fix setting up documentation
1 parent 0854c18 commit fc4e71b

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ as a template. For basic configuration and usage you need to set the following e
6666
```
6767
PINTEREST_APP_ID=<app id>
6868
PINTEREST_APP_SECRET=<app secret>
69-
7069
PINTEREST_REFRESH_ACCESS_TOKEN='<refresh token>'
70+
7171
**or**
72+
7273
PINTEREST_ACCESS_TOKEN='<access token>'
7374
```
7475

@@ -102,6 +103,7 @@ as a template. For basic configuration and usage you need to set the following k
102103
Once you have established the keys, the client will be instantiated for you automatically.
103104

104105
**NOTE**:
106+
* Setting up environment variables and config.json will result in the environment variables overriding the keys in config.json
105107
* Setting the `access_token` (which is valid for thirty days) will require the token value to be replaced when it expires. You will need to manually reinsantiate the client when the **access_token** expires.
106108
* Setting the `refresh_access_token` (which is valid for a year) will allow the SDK to regenerate the new access token whenever it is required.
107109

@@ -217,6 +219,44 @@ Additional information about campaigns and campaign management can be found in:
217219
* The [campaign objectives](https://help.pinterest.com/en/business/article/campaign-objectives) help article
218220
* The [campaign budgets](https://help.pinterest.com/en/business/article/set-up-campaign-budgets) help article
219221

222+
## Advanced Options
223+
224+
### Importing the PinterestSDKClient
225+
226+
In order to access or use the client you can import the *PinterestSDKClient* and call the `create_default_client()` classmethod:
227+
228+
```python
229+
from pinterest.client import PinterestSDKClient
230+
default_client = PinterestSDKClient.create_default_client()
231+
```
232+
233+
This will allow you to use the SDK Models without passing a **PinterestSDKClient** Object.
234+
235+
### Creating custom Pinterest SDK Clients
236+
237+
In order to create an object of the [**PinterestSDKClient**](./pinterest/client/__init__.py) you need to pass the access token inside the python code every time you wish to create a client or a combination of the refresh token, app id and app secret. This option is more useful if you wish to work with multiple accounts or clients at the same time.
238+
239+
```python
240+
from pinterest.client import PinterestSDKClient
241+
242+
# Access Token for Client 1
243+
pinterest_access_token_1 = <access token 1>
244+
245+
# Refresh Token for Client 2
246+
pinterest_refresh_token_2 = <refresh token 2>
247+
pinterest_app_id_2 = <app id 2>
248+
pinterest_app_secret_2 = <app secret 2>
249+
250+
client_1 = PinterestSDKClient.create_client_with_token(
251+
access_token=pinterest_access_token_1,
252+
)
253+
client_2 = PinterestSDKClient.create_client_with_refresh_token(
254+
refresh_token=pinterest_access_token_2,
255+
app_id=pinterest_app_id_2,
256+
app_secret=pinterest_app_secret_2,
257+
)
258+
```
259+
220260
## License
221261

222262
Pinterest Python SDK is licensed under the [LICENSE](https://github.com/pinterest/pinterest-python-sdk/blob/main/LICENSE) file in the root directory of this source tree.

0 commit comments

Comments
 (0)