def test_generate_authorization_url(self):
     app_config_path = os.path.join(os.path.split(__file__)[0], 'config', 'ebay-config-sample-user.yaml')
     credentialutil.load(app_config_path)
     oauth2api_inst = oauth2api()
     signin_url = oauth2api_inst.generate_user_authorization_url(environment.SANDBOX, app_scopes)
     self.assertIsNotNone(signin_url)
     print '\n *** test_get_signin_url ***: \n', signin_url
示例#2
0
 def test_invalid_oauth_scope(self):
     config_path = os.path.join(os.path.split(__file__)[0], 'config' ,'ebay-config-sample.yaml')
     credentialutil.load(config_path)
     oauth2api_inst = oauth2api()
     app_token = oauth2api_inst.get_application_token(environment.SANDBOX, invalid_app_scopes)
     self.assertIsNone(app_token.access_token)
     self.assertIsNotNone(app_token.error)
     print '\n *** test_invalid_oauth_scope ***\n', app_token
示例#3
0
 def test_client_credentials_grant_production(self):
     config_path = os.path.join(os.path.split(__file__)[0], 'config' ,'ebay-config-sample.yaml')
     credentialutil.load(config_path)
     oauth2api_inst = oauth2api()
     app_token = oauth2api_inst.get_application_token(environment.PRODUCTION, app_scopes)
     self.assertIsNone(app_token.error)
     self.assertIsNotNone(app_token.access_token)
     self.assertTrue(len(app_token.access_token) > 0)
     print '\n *** test_client_credentials_grant_production ***:\n', app_token   
 def test_exchange_authorization_code(self):
     app_config_path = os.path.join(os.path.split(__file__)[0], 'config', 'ebay-config-sample-user.yaml')
     credentialutil.load(app_config_path)
     oauth2api_inst = oauth2api()
     signin_url = oauth2api_inst.generate_user_authorization_url(environment.SANDBOX, app_scopes)
     code = TestUtil.get_authorization_code(signin_url)
     user_token = oauth2api_inst.exchange_code_for_access_token(environment.SANDBOX, code)
     self.assertIsNotNone(user_token.access_token)
     self.assertTrue(len(user_token.access_token) > 0)
     print '\n *** test_get_user_access_token ***:\n', user_token
示例#5
0
class RequestStat:
    def _init_(self):
        self.goodid = 0
        self.start_date = datetime()
        self.finish_date = datetime()

# Словарик со значениями данных пользователя
StatRequests = dict()


# Работа с oauth2
oauth2api_inst = oauth2api()

user_access_token = None

credentialutil.load('ebay-config.yaml')

scopes = ['https://api.ebay.com/oauth/api_scope',
          'https://api.ebay.com/oauth/api_scope/buy.order.readonly',
          'https://api.ebay.com/oauth/api_scope/buy.guest.order',
          'https://api.ebay.com/oauth/api_scope/sell.marketing.readonly',
          'https://api.ebay.com/oauth/api_scope/sell.marketing',
          'https://api.ebay.com/oauth/api_scope/sell.inventory.readonly',
          'https://api.ebay.com/oauth/api_scope/sell.inventory',
          'https://api.ebay.com/oauth/api_scope/sell.account.readonly',
          'https://api.ebay.com/oauth/api_scope/sell.account',
          'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly',
          'https://api.ebay.com/oauth/api_scope/sell.fulfillment',
          'https://api.ebay.com/oauth/api_scope/sell.analytics.readonly',
          'https://api.ebay.com/oauth/api_scope/sell.marketplace.insights.readonly',
          'https://api.ebay.com/oauth/api_scope/commerce.catalog.readonly',
示例#6
0
"""Used after you have refresh tokens for ebay business accounts received by ebay-oauth-python-client app.
This 'UpdateTrackings' app queries tracking information of orders and then fills up this information to google sheets
where all required information for business managers is stored"""

import refresh_token
from cmd_args_settings import EbaySettings, GSheetsSettings, args
from oauthclient.model.model import environment
import ebay_manager
from oauthclient.credentialutil import credentialutil
import update_google_sheet

if __name__ == "__main__":
    #credentials are used in oauth2api() and get_ebay_orders
    credentialutil.load(args.dev_creds_path)
    dev_credentials = credentialutil.get_credentials(environment.PRODUCTION)

    email2acc_token = refresh_token.get_access_tokens(args.refr_tokens_path,
                                                      environment.PRODUCTION,
                                                      EbaySettings.app_scopes)
    order_id2tracking = {}
    for email, access_token in email2acc_token.items():
        order_id2tracking.update(
            ebay_manager.get_order2tracking(dev_credentials, access_token))
    update_google_sheet.update(
        GSheetsSettings.DEFAULT_GSHEETS_CREDENTIALS_PATH, order_id2tracking)