Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Upgrade security in sample code for authentication in README #265

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ It will prompt you for your app's Client ID, Client Secret, and Redirect URI, an
### Authenticating a user

The provided sample app shows a simple OAuth flow for authenticating a user and getting an access token for them.
For security reasons, it is recommended not to write sensitive information in the code. They could be instead be stored in a separate file (i.e. one per line).

### Using an access token

Expand All @@ -59,8 +60,9 @@ Once you have an access token (whether via the script or from the user flow), yo
``` python
from instagram.client import InstagramAPI

access_token = "YOUR_ACCESS_TOKEN"
client_secret = "YOUR_CLIENT_SECRET"
with open("login_credentials.txt", "r") as f:
access_token = f.readline()
client_secret = f.readline()
api = InstagramAPI(access_token=access_token, client_secret=client_secret)
recent_media, next_ = api.user_recent_media(user_id="userid", count=10)
for media in recent_media:
Expand All @@ -73,7 +75,10 @@ For methods that don't require authentication, you can just pass your client ID
constructor:

``` python
api = InstagramAPI(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET')
with open("client_credentials.txt", "r") as f:
c_id = f.readline()
c_secret = f.readline()
api = InstagramAPI(client_id=c_id, client_secret=c_secret)
popular_media = api.media_popular(count=20)
for media in popular_media:
print media.images['standard_resolution'].url
Expand Down