我有问题,当尝试登录与API的生活帐户,而在沙箱所有工作很好。在登录时执行请求时,我必须获取响应数据对象login_accounts。对象中的数据如下所示(出于安全考虑,我已经删除了密码中的几个符号)
``` {'api_password': 'ZQQ+oSUO1alRWlCapJ0=',‘'login_accounts':[{'account_id':'4342454',
'account_id_guid': '6765dcc3-5dc6-4340-8240-9a53d3e728ab', 'base_url': 'https://demo.docusign.net/restapi/v2/accounts/4342454', 'email': 'blahblahblah@gmail.com', 'is_default': 'true', 'login_account_settings': None, 'login_user_settings': None, 'name': 'Moonshot Capital', 'site_description': '', 'user_id': '1c960342-458b-4b33-b7ae-68ff9817bbb6', 'user_name': 'Here some name'}]}```That was my sandbox data. But in live account I've get only empty object
```javascript{'api_password':无,'login_accounts':无}
If that was an error with login, I sould get something like 'bad auth' error code or something like this, but everywhere is 'http200 ok'. In system logs, that I can download from docusign service, I get only one error 404 on image object because in profile there no image, all other requests have code 'http200'. I thought that problem may be in integrator key and i've create another one, but it gives me same empty object. Also all my integration was working in free trial period on live account, and stops working after swithcing to BasicAPI billing plan. I am using official python lib [https://github.com/docusign/docusign-python-client](https://github.com/docusign/docusign-python-client) Here is my code sample
```javascriptdef setUp():
# setting local configurationapi_client = docusign.ApiClient(BASE_URL)oauth_login_url = api_client.get_jwt_uri(integrator_key, redirect_uri, oauth_base_url)try: api_client.configure_jwt_authorization_flow(private_key_filename, oauth_base_url, integrator_key, api_username, 3600) docusign.configuration.api_client = api_client return api_clientexcept: logger.exception('') print(("If you login for first time please follow the url and give the" " access for app.\n"), oauth_login_url)def docusign_login(api_client):
auth_api = AuthenticationApi()try: login_info = auth_api.login(api_password='true', include_account_id_guid='true') assert login_info is not None assert len(login_info.login_accounts) > 0 login_accounts = login_info.login_accounts assert login_accounts[0].account_id is not None logger.info(login_info) base_url, _ = login_accounts[0].base_url.split('/v2') api_client.host = base_url docusign.configuration.api_client = api_client return login_accountsexcept ApiException: logger.exception('')def request_signature_for_template(client_id):
api_client = setUp()try: login_accounts = docusign_login(api_client) envelopes_api = EnvelopesApi() envelope_summary = envelopes_api.create_envelope( login_accounts[0].account_id, envelope_definition=envelope_definition)发布于 2018-08-09 00:47:31
AuthenticationApi.login()方法旨在与传统标头身份验证一起使用。对于JWT/OAuth,您可能希望使用Get UserInfo方法。不幸的是,该方法还没有在Python客户端中实现。您需要在SDK中手动调用更新以包含该功能。下面是一个使用Requests包的示例。
oauth_base_url = "account-d.docusign.com" #use account.docusign.com for Prod
api_client.configure_jwt_authorization_flow(private_key, oauth_base_url, integrator_key, user_id, 3600)
docusign.configuration.api_client = api_client
# using Requests to manually call userinfo endpoint
user_info_url = "https://" + oauth_base_url + "/oauth/userinfo"
request_auth_header = {'Authorization' : api_client.default_headers['Authorization']}
r = requests.get(user_info_url, headers=request_auth_header)
# parse response to pull default account
for a in r.json().get('accounts'):
if a.get('is_default'):
account_id = a.get('account_id')
new_base_url = a.get('base_uri') + "/restapi"
api_client.host = new_base_url
docusign.configuration.api_client = api_clienthttps://stackoverflow.com/questions/51720851
复制相似问题