-
Notifications
You must be signed in to change notification settings - Fork 46
/
oauth_scope.py
69 lines (56 loc) · 2.17 KB
/
oauth_scope.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from enum import Enum
class Scope(Enum):
"""
Enumerate the valid OAuth scopes.
For details, see: https://developers.pinterest.com/docs/getting-started/authentication-and-scopes/#pinterest-scopes
""" # noqa: E501 because the long URL is okay
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"
READ_SECRET_BOARDS = "boards:read_secret"
WRITE_SECRET_BOARDS = "boards:write_secret"
READ_SECRET_PINS = "pins:read_secret"
WRITE_SECRET_PINS = "pins:write_secret"
READ_ADVERTISERS = "ads:read"
def lookup_scope(key):
if key == "help":
print_scopes()
exit(0)
try:
return Scope[key.upper()]
except KeyError:
# key did not work. try looking up by value.
value = key.lower() # case independent
for scope in Scope:
if value == scope.value:
return scope
print("Invalid scope:", key)
print_scopes()
exit(1)
def print_scopes():
print(
"""\
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
pins:write_secret Write access to create, update, or delete secret Pins
user_accounts:read Read access to user accounts
For more information, see:
https://developers.pinterest.com/docs/getting-started/authentication-and-scopes/#pinterest-scopes\
""" # noqa: E501 because the long URL is okay
)