Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support new scopes #96

Merged
merged 2 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,16 @@ $ ./scripts/get_access_token.js --scopes help
Using application ID and secret from PINTEREST_APP_ID and PINTEREST_APP_SECRET.
Valid OAuth 2.0 scopes for Pinterest API version v5:
ads:read Read access to advertising data
ads:write Write access to advertising data

boards:read Read access to boards
boards:read_secret Read access to secret boards
boards:write Write access to create, update, or delete boards
boards:write_secret Write access to create, update, or delete secret boards

catalogs:read Read access to catalog information
catalogs:write Create or update catalog contents

pins:read Read access to Pins
pins:read_secret Read access to secret Pins
pins:write Write access to create, update, or delete Pins
Expand Down Expand Up @@ -208,8 +212,8 @@ Retrieves all of the boards for a user with the `/v5/boards` [endpoint](https://
```
$ ./scripts/get_user_boards.js --help

usage: get_user_boards.js [-h] [-ps PAGE_SIZE] [--include-empty] [--no-include-empty] [--include-archived] [--no-include-archived]
[-a ACCESS_TOKEN] [-l LOG_LEVEL]
usage: get_user_boards.js [-h] [-ps PAGE_SIZE] [--include-empty] [--no-include-empty] [--include-archived]
[--no-include-archived] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Get A User's Boards

Expand Down Expand Up @@ -261,8 +265,8 @@ Demonstration of how to use the `POST /v5/boards` [endpoint](https://developers.
```
$ ./scripts/copy_board.js --help

usage: copy_board.js [-h] [-b BOARD_ID] [-n NAME] [-s SOURCE_ACCESS_TOKEN] [-t TARGET_ACCESS_TOKEN] [--all] [--dry-run] [-a ACCESS_TOKEN]
[-l LOG_LEVEL]
usage: copy_board.js [-h] [-b BOARD_ID] [-n NAME] [-s SOURCE_ACCESS_TOKEN] [-t TARGET_ACCESS_TOKEN] [--all]
[--dry-run] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Copy one Board or all Boards

Expand Down Expand Up @@ -290,8 +294,8 @@ Reads information about advertiser accounts, campaigns, ad groups, and ads. By d
```
$ ./scripts/get_ads.js --help

usage: get_ads.js [-h] [--all-ads] [--ad-account-id AD_ACCOUNT_ID] [--campaign-id CAMPAIGN_ID] [--ad-group-id AD_GROUP_ID] [--ad-id AD_ID]
[-a ACCESS_TOKEN] [-l LOG_LEVEL]
usage: get_ads.js [-h] [--all-ads] [--ad-account-id AD_ACCOUNT_ID] [--campaign-id CAMPAIGN_ID]
[--ad-group-id AD_GROUP_ID] [--ad-id AD_ID] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Advertisers API Example

Expand Down Expand Up @@ -319,8 +323,8 @@ Demonstrates how to use the API to retrieve analytics metrics with synchronous r
$ ./scripts/get_analytics.js --help

usage: get_analytics.js [-h] [-o {user,pin,ad_account_user,ad_account,campaign,ad_group,ad}] [--pin-id PIN_ID]
[--ad-account-id AD_ACCOUNT_ID] [--campaign-id CAMPAIGN_ID] [--ad-group-id AD_GROUP_ID] [--ad-id AD_ID]
[-a ACCESS_TOKEN] [-l LOG_LEVEL]
[--ad-account-id AD_ACCOUNT_ID] [--campaign-id CAMPAIGN_ID] [--ad-group-id AD_GROUP_ID]
[--ad-id AD_ID] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Get Analytics

Expand Down
7 changes: 7 additions & 0 deletions nodejs/src/oauth_scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import Enum from 'enum';
export const Scope = new Enum({
// scopes names that are compatible across different API versions
READ_ADS: 'ads:read',
WRITE_ADS: 'ads:write',
READ_BOARDS: 'boards:read',
WRITE_BOARDS: 'boards:write',
READ_CATALOGS: 'catalogs:read',
WRITE_CATALOGS: 'catalogs:write',
READ_PINS: 'pins:read',
WRITE_PINS: 'pins:write',
READ_USERS: 'user_accounts:read',
Expand Down Expand Up @@ -35,12 +38,16 @@ export function print_scopes() {
console.log(`\
Valid OAuth 2.0 scopes for Pinterest API version v5:
ads:read Read access to advertising data
ads:write Write access to advertising data

boards:read Read access to boards
boards:read_secret Read access to secret boards
boards:write Write access to create, update, or delete boards
boards:write_secret Write access to create, update, or delete secret boards

catalogs:read Read access to catalog information
catalogs:write Create or update catalog contents

pins:read Read access to Pins
pins:read_secret Read access to secret Pins
pins:write Write access to create, update, or delete Pins
Expand Down
40 changes: 22 additions & 18 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ usage: get_access_token.py [-h] [-w] [-ct] [-s SCOPES] [-a ACCESS_TOKEN] [-l LOG

Get Pinterest OAuth token

optional arguments:
options:
-h, --help show this help message and exit
-w, --write write access token to file
-ct, --cleartext print the token in clear text
Expand All @@ -80,12 +80,16 @@ $ ./scripts/get_access_token.py --scopes help
Using application ID and secret from PINTEREST_APP_ID and PINTEREST_APP_SECRET.
Valid OAuth 2.0 scopes for Pinterest API version v5:
ads:read Read access to advertising data
ads:write Write access to advertising data

boards:read Read access to boards
boards:read_secret Read access to secret boards
boards:write Write access to create, update, or delete boards
boards:write_secret Write access to create, update, or delete secret boards

catalogs:read Read access to catalog information
catalogs:write Create or update catalog contents

pins:read Read access to Pins
pins:read_secret Read access to secret Pins
pins:write Write access to create, update, or delete Pins
Expand All @@ -108,7 +112,7 @@ usage: refresh_example.py [-h] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Refresh Pinterest OAuth token

optional arguments:
options:
-h, --help show this help message and exit
-a ACCESS_TOKEN, --access-token ACCESS_TOKEN
access token name
Expand All @@ -125,7 +129,7 @@ usage: refresh_access_token.py [-h] [-ct] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Refresh Pinterest OAuth token

optional arguments:
options:
-h, --help show this help message and exit
-ct, --cleartext print the token in clear text
-a ACCESS_TOKEN, --access-token ACCESS_TOKEN
Expand All @@ -144,7 +148,7 @@ usage: get_pin.py [-h] -p PIN_ID [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Get a Pin

optional arguments:
options:
-h, --help show this help message and exit
-p PIN_ID, --pin-id PIN_ID
pin identifier
Expand All @@ -164,7 +168,7 @@ usage: get_board.py [-h] -b BOARD_ID [--pins] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Get a Board

optional arguments:
options:
-h, --help show this help message and exit
-b BOARD_ID, --board-id BOARD_ID
board identifier
Expand All @@ -185,7 +189,7 @@ usage: get_user_pins.py [-h] [-ps PAGE_SIZE] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Get A User's Pins

optional arguments:
options:
-h, --help show this help message and exit
-ps PAGE_SIZE, --page-size PAGE_SIZE
Pins per page
Expand All @@ -201,12 +205,12 @@ Retrieves all of the boards for a user with the `/v5/boards` [endpoint](https://
```
$ ./scripts/get_user_boards.py --help

usage: get_user_boards.py [-h] [-ps PAGE_SIZE] [--include-empty] [--no-include-empty] [--include-archived] [--no-include-archived]
[-a ACCESS_TOKEN] [-l LOG_LEVEL]
usage: get_user_boards.py [-h] [-ps PAGE_SIZE] [--include-empty] [--no-include-empty] [--include-archived]
[--no-include-archived] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Get A User's Boards

optional arguments:
options:
-h, --help show this help message and exit
-ps PAGE_SIZE, --page-size PAGE_SIZE
Boards per page
Expand All @@ -230,7 +234,7 @@ usage: copy_pin.py [-h] -p PIN_ID [-m MEDIA] -b BOARD_ID [-s SECTION] [-a ACCESS

Copy a Pin

optional arguments:
options:
-h, --help show this help message and exit
-p PIN_ID, --pin-id PIN_ID
source pin identifier
Expand All @@ -252,12 +256,12 @@ optional arguments:
```
$ ./scripts/copy_board.py --help

usage: copy_board.py [-h] [-b BOARD_ID] [-n NAME] [-s SOURCE_ACCESS_TOKEN] [-t TARGET_ACCESS_TOKEN] [--all] [--dry-run] [-a ACCESS_TOKEN]
[-l LOG_LEVEL]
usage: copy_board.py [-h] [-b BOARD_ID] [-n NAME] [-s SOURCE_ACCESS_TOKEN] [-t TARGET_ACCESS_TOKEN] [--all]
[--dry-run] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Copy one Board or all Boards

optional arguments:
options:
-h, --help show this help message and exit
-b BOARD_ID, --board-id BOARD_ID
source board identifier
Expand All @@ -284,7 +288,7 @@ usage: get_ads.py [-h] [--all-ads] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Advertisers API Example

optional arguments:
options:
-h, --help show this help message and exit
--all-ads print all ads information
-a ACCESS_TOKEN, --access-token ACCESS_TOKEN
Expand All @@ -300,12 +304,12 @@ optional arguments:
$ ./scripts/get_analytics.py --help

usage: get_analytics.py [-h] [-o {user,pin,ad_account_user,ad_account,campaign,ad_group,ad}] [--pin-id PIN_ID]
[--ad-account-id AD_ACCOUNT_ID] [--campaign-id CAMPAIGN_ID] [--ad-group-id AD_GROUP_ID] [--ad-id AD_ID]
[-a ACCESS_TOKEN] [-l LOG_LEVEL]
[--ad-account-id AD_ACCOUNT_ID] [--campaign-id CAMPAIGN_ID] [--ad-group-id AD_GROUP_ID]
[--ad-id AD_ID] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Get Analytics

optional arguments:
options:
-h, --help show this help message and exit
-o {user,pin,ad_account_user,ad_account,campaign,ad_group,ad}, --analytics-object {user,pin,ad_account_user,ad_account,campaign,ad_group,ad}
kind of object used to fetch analytics
Expand Down Expand Up @@ -334,7 +338,7 @@ usage: analytics_api_example.py [-h] [-a ACCESS_TOKEN] [-l LOG_LEVEL]

Analytics API Example

optional arguments:
options:
-h, --help show this help message and exit
-a ACCESS_TOKEN, --access-token ACCESS_TOKEN
access token name
Expand Down
7 changes: 7 additions & 0 deletions python/src/oauth_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
# For details, see: https://developers.pinterest.com/docs/getting-started/scopes/
class Scope(Enum):
READ_ADS = "ads:read"
WRITE_ADS = "ads:write"
READ_BOARDS = "boards:read"
WRITE_BOARDS = "boards:write"
READ_CATALOGS = "catalogs:read"
WRITE_CATALOGS = "catalogs:write"
READ_PINS = "pins:read"
WRITE_PINS = "pins:write"
READ_USERS = "user_accounts:read"
Expand Down Expand Up @@ -40,12 +43,16 @@ def print_scopes():
"""\
Valid OAuth 2.0 scopes for Pinterest API version v5:
ads:read Read access to advertising data
ads:write Write access to advertising data

boards:read Read access to boards
boards:read_secret Read access to secret boards
boards:write Write access to create, update, or delete boards
boards:write_secret Write access to create, update, or delete secret boards

catalogs:read Read access to catalog information
catalogs:write Create or update catalog contents

pins:read Read access to Pins
pins:read_secret Read access to secret Pins
pins:write Write access to create, update, or delete Pins
Expand Down
Loading