def identity_properties(self): """ Retrieve and cache the Identity version 2 module's properties. """ url = self.identity_base + "properties" if not hasattr(self, "_identity_properties"): self._identity_properties = identity.parse(self._request(url)).properties return self._identity_properties
def identity_properties(self): """ Retrieve and cache the Identity version 2 module's properties. """ url = self.identity_base + 'properties' if not hasattr(self, '_identity_properties'): self._identity_properties = identity.parse( self._request(url)).properties return self._identity_properties
def session(self): """ Keep the current session in an active state by sending an empty request. Calling this method is an easy way to turn a sessionId query parameter into a cookie without doing anything else. """ url = self.identity_base + "session" self.session_id = identity.parse(self._request(url)).session.id self.logged_in = True return self.session_id
def session(self): """ Keep the current session in an active state by sending an empty request. Calling this method is an easy way to turn a sessionId query parameter into a cookie without doing anything else. """ url = self.identity_base + 'session' self.session_id = identity.parse(self._request(url)).session.id self.logged_in = True return self.session_id
def initialize(self): """ Initialize a FamilySearch session using Basic Authentication. This creates an unauthenticated session and should be followed by an authenticate call. Web applications must use OAuth. """ self.logged_in = False self.cookies.clear() url = self.identity_base + "initialize" key = urllib.urlencode({"key": self.key}) self.session_id = identity.parse(self._request(url, key)).session.id return self.session_id
def login(self, username, password): """ Log into FamilySearch using Basic Authentication. Web applications must use OAuth. """ self.logged_in = False self.cookies.clear() url = self.identity_base + "login" credentials = urllib.urlencode({"username": username, "password": password, "key": self.key}) self.session_id = identity.parse(self._request(url, credentials)).session.id self.logged_in = True return self.session_id
def initialize(self): """ Initialize a FamilySearch session using Basic Authentication. This creates an unauthenticated session and should be followed by an authenticate call. Web applications must use OAuth. """ self.logged_in = False self.cookies.clear() url = self.identity_base + 'initialize' key = urllib.urlencode({'key': self.key}) self.session_id = identity.parse(self._request(url, key)).session.id return self.session_id
def authenticate(self, username, password): """ Authenticate a FamilySearch session using Basic Authentication. This should follow an initialize call. Web applications must use OAuth. """ url = self.identity_base + "authenticate" credentials = {"username": username, "password": password} if not self.cookies and self.session_id: # Set sessionId parameter if the session ID is not set in a cookie credentials["sessionId"] = self.session_id credentials = urllib.urlencode(credentials) self.session_id = identity.parse(self._request(url, credentials)).session.id self.logged_in = True return self.session_id
def authenticate(self, username, password): """ Authenticate a FamilySearch session using Basic Authentication. This should follow an initialize call. Web applications must use OAuth. """ url = self.identity_base + 'authenticate' credentials = {'username': username, 'password': password} if not self.cookies and self.session_id: # Set sessionId parameter if the session ID is not set in a cookie credentials['sessionId'] = self.session_id credentials = urllib.urlencode(credentials) self.session_id = identity.parse(self._request(url, credentials)).session.id self.logged_in = True return self.session_id
def login(self, username, password): """ Log into FamilySearch using Basic Authentication. Web applications must use OAuth. """ self.logged_in = False self.cookies.clear() url = self.identity_base + 'login' credentials = urllib.urlencode({ 'username': username, 'password': password, 'key': self.key }) self.session_id = identity.parse(self._request(url, credentials)).session.id self.logged_in = True return self.session_id
import random import time import urllib import urllib2 import urlparse import web from enunciate import identity consumer_key = 'WCQY-7J1Q-GKVV-7DNM-SQ5M-9Q5H-JX3H-CMJK' consumer_secret = '' familysearch_base_url = 'http://www.dev.usys.org' properties_url = familysearch_base_url + '/identity/v2/properties' + '?dataFormat=application/json' properties = identity.parse(urllib2.urlopen(properties_url)).properties request_token_url = properties["request.token.url"] authorize_url = properties["authorize.url"] access_token_url = properties["access.token.url"] urls = ( '/', 'login', '/authorized', 'authorized', ) app = web.application(urls, globals()) def oauth_request(url, consumer_key, consumer_secret, token_secret="", params={}): url = list(urlparse.urlparse(url)) query = dict(urlparse.parse_qsl(url[4])) query.update(params)