def test_credentials_to_from_json(self):
     private_key = datafile("privatekey.p12")
     credentials = SignedJwtAssertionCredentials(
         "*****@*****.**", private_key, scope="read+write", prn="*****@*****.**"
     )
     json = credentials.to_json()
     restored = Credentials.new_from_json(json)
     self.assertEqual(credentials.private_key, restored.private_key)
     self.assertEqual(credentials.private_key_password, restored.private_key_password)
     self.assertEqual(credentials.kwargs, restored.kwargs)
Example #2
0
 def test_credentials_to_from_json(self):
     private_key = datafile('privatekey.%s' % self.format)
     credentials = SignedJwtAssertionCredentials('*****@*****.**',
                                                 private_key,
                                                 scope='read+write',
                                                 sub='*****@*****.**')
     json = credentials.to_json()
     restored = Credentials.new_from_json(json)
     self.assertEqual(credentials.private_key, restored.private_key)
     self.assertEqual(credentials.private_key_password,
                      restored.private_key_password)
     self.assertEqual(credentials.kwargs, restored.kwargs)
 def test_credentials_to_from_json(self):
   private_key = datafile('privatekey.%s' % self.format)
   credentials = SignedJwtAssertionCredentials(
       '*****@*****.**',
       private_key,
       scope='read+write',
       sub='*****@*****.**')
   json = credentials.to_json()
   restored = Credentials.new_from_json(json)
   self.assertEqual(credentials.private_key, restored.private_key)
   self.assertEqual(credentials.private_key_password,
                    restored.private_key_password)
   self.assertEqual(credentials.kwargs, restored.kwargs)
f = file(config.SERVICE_ACCOUNT_PRIVATE_KEY, 'rb')
key = f.read()
f.close()

# Create an httplib2.Http object to handle our HTTP requests and authorize it
# with the Credentials. Note that the first parameter, service_account_name,
# is the Email address created for the Service account. It must be the email
# address associated with the key that was created.
credentials = SignedJwtAssertionCredentials(
    config.SERVICE_ACCOUNT_EMAIL_ADDRESS,
    key,
    scope='https://www.googleapis.com/auth/wallet_object.issuer')
http = httplib2.Http()
http = credentials.authorize(http)

logging.info('Credentials: %s' % credentials.to_json())
f = file(config.DISCOVERY_JSON, 'rb')
disc_content = f.read()
f.close()

#service = build('walletobjects', 'v1', http=http)
service = build_from_document(disc_content,'walletobjects', http=http)


def displayIndex(request):
  """Serves the index page.

  Args:
    request: A HTTP request object.

  Returns: