# Maps Instagram media type to ActivityStreams objectType. OBJECT_TYPES = {'image': 'photo', 'video': 'video'} API_USER_URL = 'https://api.instagram.com/v1/users/%s' API_USER_MEDIA_URL = 'https://api.instagram.com/v1/users/%s/media/recent' API_USER_FEED_URL = 'https://api.instagram.com/v1/users/self/feed' API_USER_LIKES_URL = 'https://api.instagram.com/v1/users/%s/media/liked' API_MEDIA_URL = 'https://api.instagram.com/v1/media/%s' API_MEDIA_SEARCH_URL = 'https://api.instagram.com/v1/tags/%s/media/recent' API_MEDIA_SHORTCODE_URL = 'https://api.instagram.com/v1/media/shortcode/%s' API_MEDIA_POPULAR_URL = 'https://api.instagram.com/v1/media/popular' API_MEDIA_LIKES_URL = 'https://api.instagram.com/v1/media/%s/likes' API_COMMENT_URL = 'https://api.instagram.com/v1/media/%s/comments' HTML_BASE_URL = (appengine_config.read('instagram_scrape_base') or 'https://www.instagram.com/') HTML_MEDIA = HTML_BASE_URL + 'p/%s/' HTML_PROFILE = HTML_BASE_URL + '%s/' # URL-safe base64 encoding. used in Instagram.id_to_shortcode() BASE64 = string.ascii_uppercase + string.ascii_lowercase + string.digits + '-_' MENTION_RE = re.compile(r'@([A-Za-z0-9._]+)') class Instagram(source.Source): """Implements the ActivityStreams API for Instagram.""" DOMAIN = 'instagram.com' BASE_URL = 'https://www.instagram.com/'
import appengine_config import httplib2 from apiclient import discovery from apiclient import http appengine_config.GOOGLE_CLIENT_ID = 'my client id' appengine_config.GOOGLE_CLIENT_SECRET = 'my client secret' import googleplus from oauth_dropins import googleplus as oauth_googleplus from oauth_dropins.webutil import testutil from oauth_dropins.webutil import util DISCOVERY_DOC = appengine_config.read('googleplus_api_discovery.json') def tag_uri(name): return util.tag_uri('plus.google.com', name) ACTIVITY_GP = { # Google+ 'kind': 'plus#activity', 'verb': 'post', 'id': '001', 'actor': {'id': '444', 'displayName': 'Charles'}, 'object': { 'content': 'my post', 'url': 'http://plus.google.com/001', }, }
import logging import os import urllib import urlparse from webob import exc from webutil import handlers from webutil import util from django_salmon import magicsigs from google.appengine.ext import db from google.appengine.ext.webapp.util import run_wsgi_app import tweepy import webapp2 TWITTER_ACCESS_TOKEN_KEY = appengine_config.read('twitter_access_token_key') TWITTER_ACCESS_TOKEN_SECRET = appengine_config.read( 'twitter_access_token_secret') class User(db.Model): """Stores a user's public/private key pair used for Magic Signatures. The key name is the user URI, including the acct: prefix. The modulus and exponent properties are all encoded as base64url (ie URL-safe base64) strings as described in RFC 4648 and section 5.1 of the Magic Signatures spec. Magic Signatures are used to sign Salmon slaps. Details: http://salmon-protocol.googlecode.com/svn/trunk/draft-panzer-magicsig-01.html
import urlparse from activitystreams import activitystreams import appengine_config import models import tumblpy from webob import exc from webutil import util from google.appengine.api import urlfetch from google.appengine.ext import db from google.appengine.ext.webapp import template import webapp2 # http://www.tumblr.com/oauth/apps TUMBLR_APP_KEY = appengine_config.read('tumblr_app_key') TUMBLR_APP_SECRET = appengine_config.read('tumblr_app_secret') OAUTH_CALLBACK_URL = '%s://%s/tumblr/oauth_callback' % ( appengine_config.SCHEME, appengine_config.HOST) class TumblrOAuthRequestToken(models.OAuthToken): pass class TumblrOAuthFinalToken(models.OAuthToken): pass class Tumblr(models.Destination):
import appengine_config from python_dropbox.client import DropboxOAuth2Flow, DropboxClient import models from webob import exc from webutil import util from google.appengine.api import urlfetch from google.appengine.ext import db from google.appengine.ext.webapp import template import webapp2 TITLE_MAX_LEN = 40 REAL_DOMAIN = 'www.freedom.io' APPSPOT_DOMAIN = 'freedom-io-app.appspot.com' DROPBOX_APP_KEY = appengine_config.read('dropbox_app_key') DROPBOX_APP_SECRET = appengine_config.read('dropbox_app_secret') OAUTH_CALLBACK = 'https://%s/dropbox/oauth_callback' % APPSPOT_DOMAIN CSRF_PARAM = 'dropbox-auth-csrf-token' class DropboxCsrf(db.Model): """Stores a CSRF token for the Dropbox OAuth2 flow.""" token = db.StringProperty(required=False) class Dropbox(models.Destination): """A Dropbox account. The key name is the user id.""" # OAuth2 access token for this account # https://www.dropbox.com/developers/core/start/python#authenticating
import urllib import appengine_config from python_dropbox.client import DropboxOAuth2Flow, DropboxClient import models from webob import exc from webutil import util from google.appengine.api import urlfetch from google.appengine.ext import db from google.appengine.ext.webapp import template import webapp2 TITLE_MAX_LEN = 40 DROPBOX_APP_KEY = appengine_config.read('dropbox_app_key') DROPBOX_APP_SECRET = appengine_config.read('dropbox_app_secret') OAUTH_CALLBACK = 'https://freedom-io-app.appspot.com/dropbox/oauth_callback' CSRF_PARAM = 'dropbox-auth-csrf-token' class DropboxCsrf(db.Model): """Stores a CSRF token for the Dropbox OAuth2 flow.""" token = db.StringProperty(required=False) class Dropbox(models.Destination): """A Dropbox account. The key name is the user id.""" # OAuth2 access token for this account # https://www.dropbox.com/developers/core/start/python#authenticating
import logging import os import urllib import urlparse from webob import exc from webutil import handlers from webutil import util from django_salmon import magicsigs from google.appengine.ext import db from google.appengine.ext.webapp.util import run_wsgi_app import tweepy import webapp2 TWITTER_ACCESS_TOKEN_KEY = appengine_config.read('twitter_access_token_key') TWITTER_ACCESS_TOKEN_SECRET = appengine_config.read('twitter_access_token_secret') class User(db.Model): """Stores a user's public/private key pair used for Magic Signatures. The key name is the user URI, including the acct: prefix. The modulus and exponent properties are all encoded as base64url (ie URL-safe base64) strings as described in RFC 4648 and section 5.1 of the Magic Signatures spec. Magic Signatures are used to sign Salmon slaps. Details: http://salmon-protocol.googlecode.com/svn/trunk/draft-panzer-magicsig-01.html http://salmon-protocol.googlecode.com/svn/trunk/draft-panzer-salmon-00.html
"""Cron jobs. Currently just nightly CircleCI build.""" import appengine_config import requests import webapp2 CIRCLECI_TOKEN = appengine_config.read('circleci_token') class BuildCircle(webapp2.RequestHandler): def get(self): resp = requests.post('https://circleci.com/api/v1.1/project/github/snarfed/granary/tree/master?circle-token=%s' % CIRCLECI_TOKEN) resp.raise_for_status() application = webapp2.WSGIApplication([ ('/cron/build_circle', BuildCircle), ], debug=appengine_config.DEBUG)
from webutil import util from google.appengine.api import urlfetch from google.appengine.ext import db import webapp2 # https://developer.wordpress.com/docs/api/1/ API_ME_URL = 'https://public-api.wordpress.com/rest/v1/me/' API_SITE_URL = 'https://public-api.wordpress.com/rest/v1/sites/%d' CALLBACK_PATH = '/wordpress_rest/oauth_callback' if appengine_config.DEBUG: # https://developer.wordpress.com/apps/2090/ CLIENT_ID = appengine_config.read('wordpress.com_client_id_local') CLIENT_SECRET = appengine_config.read('wordpress.com_client_secret_local') CALLBACK_URL = 'http://my.dev.com:8080' + CALLBACK_PATH else: # https://developer.wordpress.com/apps/2043/ CLIENT_ID = appengine_config.read('wordpress.com_client_id') CLIENT_SECRET = appengine_config.read('wordpress.com_client_secret') CALLBACK_URL = CALLBACK_PATH TOKEN_RESPONSE_PARAM = 'token_response' oauth = OAuth2Decorator( client_id=CLIENT_ID, client_secret=CLIENT_SECRET, # can't find any mention of oauth scope in https://developer.wordpress.com/ scope='',
from activitystreams import activitystreams import appengine_config import models import tumblpy from webob import exc from webutil import util from google.appengine.api import urlfetch from google.appengine.ext import db from google.appengine.ext.webapp import template import webapp2 # http://www.tumblr.com/oauth/apps TUMBLR_APP_KEY = appengine_config.read('tumblr_app_key') TUMBLR_APP_SECRET = appengine_config.read('tumblr_app_secret') OAUTH_CALLBACK_URL = '%s://%s/tumblr/oauth_callback' % ( appengine_config.SCHEME, appengine_config.HOST) class TumblrOAuthRequestToken(models.OAuthToken): pass class TumblrOAuthFinalToken(models.OAuthToken): pass class Tumblr(models.Destination):