Beispiel #1
0
 def GET(self):
     '''
     处理安装应用时验证请求
     '''
     data = dict(web.input())
     if 'hmac' not in data or data['hmac'] != verify.cal_hmac_code(config.AppSecret, data):
         return 'hmac verify failed'
     if 'shop_key' not in data:
         return 'shop_key requires'
     # 验证通过,重定向回友好速搭
     state = None
     if 'state' in data:
         state = data['state']
     auth_url = publicapp.generate_authorize_url(redirect_uri_on_auth, data['shop_key'], state)
     #print state, data['shop_key']
     #print auth_url
     web.seeother(auth_url)
 def test_generate_authorize_url(self):
     url = 'https://apps.youhaosuda.com/oauth2/authorize?shop_key=3289572b75abe5aa618548f98d71a65e&scope=read_basic,write_basic,read_content,write_content&redirect_uri=http://localhost:8080/auth_confirm&response_type=code&client_id=5c768a6fe94f41a4a2465756383e745f'
     shop_key = '3289572b75abe5aa618548f98d71a65e'
     redirect_url = 'http://localhost:8080/auth_confirm'
     self.assertEqual(url, publicapp.generate_authorize_url(redirect_url, shop_key))