# Path: shared/gcp_jupyterlab_shared/version.py
# VERSION = '1.1.3'


import json
import os
import ssl
import google.auth
from base64 import b64decode
from google.auth.exceptions import GoogleAuthError
from google.auth.transport.requests import Request
from notebook.base.handlers import APIHandler, app_log
from tornado import web
from tornado.httpclient import AsyncHTTPClient, HTTPClientError, HTTPRequest
from .version import VERSION
  async def _make_request(self, base64_url, method='GET', body=None):
    try:
      url = b64decode(base64_url).decode()
      if not (url.startswith('https://') and 'googleapis.com' in url):
        raise ValueError('URL is not a valid Google API service')
    except ValueError as e:
      app_log.exception(e)
      self.set_status(400)
      self.finish(
          {'error': {
              'code': 400,
              'status': 'BAD_REQUEST',
              'message': str(e)
          }})
      return

    try:
      headers = AuthProvider.get().get_header()
    except:
      self.set_status(403)
      self.finish({
          'error': {
              'code': 403,
              'status': 'UNAUTHORIZED',
              'message': 'Unable to obtain authentication token'
          }
      })
      return

    headers['Content-Type'] = 'application/json'

# Path: shared/gcp_jupyterlab_shared/version.py
# VERSION = '1.1.3'


# Path: shared/gcp_jupyterlab_shared/handlers.py
import json
import os
import ssl
import google.auth
from base64 import b64decode
from google.auth.exceptions import GoogleAuthError
from google.auth.transport.requests import Request
from notebook.base.handlers import APIHandler, app_log
from tornado import web
from tornado.httpclient import AsyncHTTPClient, HTTPClientError, HTTPRequest
from .version import VERSION

  async def _make_request(self, base64_url, method='GET', body=None):
    try:
      url = b64decode(base64_url).decode()
      if not (url.startswith('https://') and 'googleapis.com' in url):
        raise ValueError('URL is not a valid Google API service')
    except ValueError as e:
      app_log.exception(e)
      self.set_status(400)
      self.finish(
          {'error': {
              'code': 400,
              'status': 'BAD_REQUEST',
              'message': str(e)
          }})
      return

    try:
      headers = AuthProvider.get().get_header()
    except:
      self.set_status(403)
      self.finish({
          'error': {
              'code': 403,
              'status': 'UNAUTHORIZED',
              'message': 'Unable to obtain authentication token'
          }
      })
      return

    headers['Content-Type'] = 'application/json'

    user_agent = 'jupyterlab_gcpextension/{}'.format(VERSION)