Skip to content

【質問】最初のトークン発行ができません。 #774

@cranfhk

Description

@cranfhk

サンプルコード kabusapi_token.py のAPIで下記のXXXXXを自分のAPI
APIパスワードに置き換えて実行したら

HTTP Error 401: Unauthorized {'Code': 4001013, 'Message': 'トークン取得失敗'}

が出てきます。これ以上進めなくて困っています。教えてください。

ちなみにAPI登録は日曜しました。平日になればトークン取得は可能になりますか?

************* kabusapi_token.py *********************************

import urllib.request
import json
import pprint

obj = { 'APIPassword': 'XXXXX' }
json_data = json.dumps(obj).encode('utf8')

url = 'http://localhost:18080/kabusapi/token'
req = urllib.request.Request(url, json_data, method='POST')
req.add_header('Content-Type', 'application/json')

try:
with urllib.request.urlopen(req) as res:
print(res.status, res.reason)
for header in res.getheaders():
print(header)
print()
content = json.loads(res.read())
pprint.pprint(content)
except urllib.error.HTTPError as e:
print(e)
content = json.loads(e.read())
pprint.pprint(content)
except Exception as e:
print(e)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions