Skip to content

Commit ccb3464

Browse files
committed
Move credentials to an INI file
So that I can add it to my ignore list and not have people accidentally commit their credentials with code
1 parent faa971a commit ccb3464

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

examples/auth.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[credentials]
2+
client_id=YOUR ID HERE
3+
client_secret=YOUR SECRET HERE
4+
refresh_token=

examples/auth.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
set up a test user with API credentials and set them up in here.
77
'''
88

9-
#client_id = 'YOUR CLIENT ID'
10-
#client_secret = 'YOUR CLIENT SECRET'
11-
12-
client_id = u'6d2d7ee5f212dc1'
13-
client_secret = u'18828c1021069154576672e86b8ab2e1559d329a'
14-
15-
169
from imgurpython import ImgurClient
1710

1811
def get_input(string):
@@ -22,7 +15,22 @@ def get_input(string):
2215
except:
2316
return input(string)
2417

18+
def get_config():
19+
''' More version compatibility stuff '''
20+
try:
21+
import ConfigParser
22+
return ConfigParser.ConfigParser()
23+
except:
24+
import configparser
25+
return configparser.ConfigParser()
26+
2527
def authenticate():
28+
# Get client ID and secret from auth.ini
29+
config = get_config()
30+
config.read('auth.ini')
31+
client_id = config['credentials']['client_id']
32+
client_secret = config['credentials']['client_secret']
33+
2634
client = ImgurClient(client_id, client_secret)
2735

2836
# Authorization flow, pin example (see docs for other auth types)

0 commit comments

Comments
 (0)