@@ -0,0 +1,1445 @@
+#!/usr/bin/env python3%0A%0A'''%0A%09Here's how you go about authenticating yourself! The important thing to%0A%09note here is that this script will be used in the other examples so%0A%09set up a test user with API credentials and set them up in here.%0A'''%0A%0A#client_id = 'YOUR CLIENT ID'%0A#client_secret = 'YOUR CLIENT SECRET'%0A%0Aclient_id = u'6d2d7ee5f212dc1'%0Aclient_secret = u'18828c1021069154576672e86b8ab2e1559d329a'%0A%0A%0Afrom imgurpython import ImgurClient%0A%0Adef get_input(string):%0A%09''' Get input from console regardless of python 2 or 3 '''%0A%09try:%0A%09%09return raw_input(string)%0A%09except:%0A%09%09return input(string)%0A%0Adef authenticate():%0A%09client = ImgurClient(client_id, client_secret)%0A%0A%09# Authorization flow, pin example (see docs for other auth types)%0A%09authorization_url = client.get_auth_url('pin')%0A%0A%09print(%22Go to the following URL: %7B0%7D%22.format(authorization_url))%0A%0A%09# Read in the pin, handle Python 2 or 3 here.%0A%09pin = get_input(%22Enter pin code: %22)%0A%0A%09# ... redirect user to %60authorization_url%60, obtain pin (or code or token) ...%0A%09credentials = client.authorize(pin, 'pin')%0A%09client.set_user_auth(credentials%5B'access_token'%5D, credentials%5B'refresh_token'%5D)%0A%0A%09print(%22Authentication successful! Here are the details:%22)%0A%09print(%22   Access token:  %7B0%7D%22.format(credentials%5B'access_token'%5D))%0A%09print(%22   Refresh token: %7B0%7D%22.format(credentials%5B'refresh_token'%5D))%0A%0A%09return client%0A%0A# If you want to run this as a standalone script, so be it!%0Aif __name__ == %22__main__%22:%0A%09authenticate()

Create standalone auth example