Ejemplo n.º 1
0
	def parse_access_token(self, record, client_secret, token_data):
		logger.info("Received access token for "+record.client_id)
		record.access_token = encrypt(client_secret, token_data['access_token'])
		record.access_sha1 = hash_sha1_64(token_data['access_token'])
		if 'expires_in' in token_data:		# required per spec
			record.access_exp = time.time() + int(token_data['expires_in'])
		elif 'expires' in token_data:		# facebook is wrong
			record.access_exp = time.time() + int(token_data['expires'])
		else:
			logger.debug("Strange, access token is missing expiration")
		if 'token_type' in token_data:		# required per spec
			record.access_token_type = token_data['token_type']
		else:
			logger.debug("Access token is missing token_type, assuming Bearer")
			record.access_token_type = 'Bearer'
		if urlparse.urlparse(record.token_uri).netloc == 'graph.facebook.com':
			self.parse_facebook_token(record, client_secret, token_data)
		self.db.commit()
		if 'refresh_token' in token_data:
			self.parse_refresh_token(record, client_secret, token_data)
Ejemplo n.º 2
0
	def parse_refresh_token(self, record, client_secret, token_data):
		if 'refresh_token' in token_data:
			logger.info("Received refresh token for "+record.client_id)
			record.refresh_token = encrypt(client_secret, token_data['refresh_token'])
			record.refresh_sha1 = hash_sha1_64(token_data['refresh_token'])
			self.db.commit()