This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from requests_oauthlib import OAuth1 | |
from flask import Flask, request, redirect, session | |
from urlparse import parse_qs | |
import os | |
app = Flask(__name__) | |
# This information is obtained upon registration of a new client on twitter | |
key = u"<your client key>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from requests_oauthlib import OAuth2Session | |
from flask import Flask, request, redirect, session, url_for | |
from flask.json import jsonify | |
import os | |
app = Flask(__name__) | |
# This information is obtained upon registration of a new GitHub | |
client_id = "<your client key>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Fetching the latest GMail email using OAuth 2 and IMAP. | |
Requires requests-oauthlib, which is available on pypi. | |
Includes a basic SASL XOAUTH2 authentication method for imaplib. | |
""" | |
# Credentials you get from registering a new web application in Google API Console | |
client_id = 'your-id.apps.googleusercontent.com' | |
client_secret = 'your secret' | |
redirect_uri = 'your callback uri' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from json import dumps | |
from flask import Flask, request, redirect, session, url_for | |
from flask.json import jsonify | |
from requests_oauthlib import OAuth2Session | |
app = Flask(__name__) | |
# Ignore this, only used as basic doc string template creator. | |
def docstring_templator(f): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Non magic version, client is only used to append tokens | |
# All other actions are explicit | |
import requests | |
from requests.auth import AuthBase | |
from oauthlib.oauth2.draft25 import WebApplicationClient | |
from oauthlib.common import urldecode | |
# Very basic auth, only used to append tokens to requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The slightly magic version, extra requests are made to obtain token | |
# and users must fetch values from client when saving them to a db | |
import requests | |
from requests.auth import AuthBase | |
from oauthlib.oauth2.draft25 import WebApplicationClient | |
from oauthlib.common import urldecode, generate_token | |
class OAuth2WebApp(WebApplicationClient, AuthBase): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Non magic version, client is only used to append tokens | |
# All other actions are explicit | |
import requests | |
from requests.auth import AuthBase | |
from oauthlib.oauth2.draft25 import WebApplicationClient | |
from oauthlib.common import urldecode | |
class OAuth2WebApp(WebApplicationClient, AuthBase): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from requests.auth import OAuth1 | |
from oauthlib.oauth1.rfc5849 import SIGNATURE_RSA | |
client_key = u'...' | |
# You need to register your key with the OAuth provider first, | |
# in this case Google at https://accounts.google.com/ManageDomains | |
key = open("your_rsa_key.pem").read() |