How to use the oauthenticator.GoogleOAuthenticator function in oauthenticator

To help you get started, we’ve selected a few oauthenticator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github compmodels / jupyterhub / docker_oauth.py View on Github external
self.log.error("Failed to create %r", user.name, exc_info=True)
            raise

        # todo: save the user id into the whitelist or somewhere
        info = json.loads(resp.body.decode('utf8', 'replace'))
        self.log.info("Created user %s with uid %i", user.name, info['uid'])
        if user.state is None:
            user.state = {}
        user.state['user_id'] = info['uid']
        self.db.commit()

        # update the state in the spawner, so that it knows the user id, etc.
        user.spawner.load_state(user.state)


class DockerOAuthenticator(DockerAuthenticator, GoogleOAuthenticator):
    """A version that mixes in local system user creation from within a
    docker container, and Google OAuthentication.

    """
    pass
github ryanlovett / jh-google-oauthenticator / oauthenticator.py View on Github external
http_client = handler.get_auth_http_client()

		response = yield http_client.fetch(
			self.ACCESS_TOKEN_URL + '?access_token=' + access_token
		)

		if not response:
			self.clear_all_cookies()
			raise HTTPError(500, 'Google authentication failed')

		bodyjs = json.loads(response.body.decode())

		username = bodyjs['email']
		raise gen.Return(username)

class GoogleAppsOAuthenticator(GoogleOAuthenticator):

	hosted_domain = Unicode(os.environ.get('HOSTED_DOMAIN', ''), config=True)

	@gen.coroutine
	def authenticate(self, handler):
		username = yield GoogleOAuthenticator.authenticate(self, handler)

		if not username or not username.endswith('@'+self.hosted_domain):
			username = None
		else:
			username = username.split('@')[0]

		if self.whitelist and username not in self.whitelist:
			username = None

		raise gen.Return(username)
github ryanlovett / jh-google-oauthenticator / oauthenticator.py View on Github external
	@gen.coroutine
	def authenticate(self, handler):
		username = yield GoogleOAuthenticator.authenticate(self, handler)

		if not username or not username.endswith('@'+self.hosted_domain):
			username = None
		else:
			username = username.split('@')[0]

		if self.whitelist and username not in self.whitelist:
			username = None

		raise gen.Return(username)

class LocalGoogleOAuthenticator(LocalAuthenticator, GoogleOAuthenticator):
	"""A version that mixes in local system user creation"""
	pass

class LocalGoogleAppsOAuthenticator(LocalAuthenticator, GoogleAppsOAuthenticator):
	"""A version that mixes in local system user creation"""
	pass