如何解决 gocardless 开发者密钥错误
how to solve gocardless developer key error
我正在尝试使用 gocardless_pro API,但我不断收到一个关键错误,我不确定如何解决。
下面是我的代码
import os
import gocardless_pro
client = gocardless_pro.Client(
access_token=os.environ['testing123'],
environment='sandbox'
)
运行 此代码单独抛出以下关键错误:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-23-2b23701d8478> in <module>
2 # We recommend storing your access token in an
3 # environment variable for security
----> 4 access_token=os.environ['testing123'],
5 # Change this to 'live' when you are ready to go live.
6 environment='sandbox'
~\Anaconda3\lib\os.py in __getitem__(self, key)
676 except KeyError:
677 # raise KeyError with the original key value
--> 678 raise KeyError(key) from None
679 return self.decodevalue(value)
680
KeyError: 'testing123'
下面是 link 我正在关注:https://developer.gocardless.com/getting-started/api/making-your-first-request/
你有两个选择。
将行 access_token=os.environ['sandbox_-VghfQfP7nNxN_arDMfAMKF9qKdyLA05teLqGDky']
更改为 access_token='sandbox_-VghfQfP7nNxN_arDMfAMKF9qKdyLA05teLqGDky'
使用您的令牌值设置一个环境变量,然后像这样引用它:
首先从命令提示符执行此操作:
$ export TOKEN=sandbox_-VghfQfP7nNxN_arDMfAMKF9qKdyLA05teLqGDky
然后像这样从 Python 引用令牌:
import os
import gocardless_pro
client = gocardless_pro.Client(
access_token = os.environ['TOKEN'],
environment='sandbox'
)
我正在尝试使用 gocardless_pro API,但我不断收到一个关键错误,我不确定如何解决。
下面是我的代码
import os
import gocardless_pro
client = gocardless_pro.Client(
access_token=os.environ['testing123'],
environment='sandbox'
)
运行 此代码单独抛出以下关键错误:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-23-2b23701d8478> in <module>
2 # We recommend storing your access token in an
3 # environment variable for security
----> 4 access_token=os.environ['testing123'],
5 # Change this to 'live' when you are ready to go live.
6 environment='sandbox'
~\Anaconda3\lib\os.py in __getitem__(self, key)
676 except KeyError:
677 # raise KeyError with the original key value
--> 678 raise KeyError(key) from None
679 return self.decodevalue(value)
680
KeyError: 'testing123'
下面是 link 我正在关注:https://developer.gocardless.com/getting-started/api/making-your-first-request/
你有两个选择。
将行
access_token=os.environ['sandbox_-VghfQfP7nNxN_arDMfAMKF9qKdyLA05teLqGDky']
更改为access_token='sandbox_-VghfQfP7nNxN_arDMfAMKF9qKdyLA05teLqGDky'
使用您的令牌值设置一个环境变量,然后像这样引用它:
首先从命令提示符执行此操作:
$ export TOKEN=sandbox_-VghfQfP7nNxN_arDMfAMKF9qKdyLA05teLqGDky
然后像这样从 Python 引用令牌:
import os
import gocardless_pro
client = gocardless_pro.Client(
access_token = os.environ['TOKEN'],
environment='sandbox'
)