When trying to follow the guide for adding API Access to restricted APIs I end up having an EOF Error.
The documentation I followed was: http://docs.bitshares.eu/api/access.html
The API Access JSON File contains:
{
"permission_map" :
[
[
"startail",
{
"password_hash_b64" : "<hash>",
"password_salt_b64" : "<salt>",
"allowed_apis" : ["asset_api"]
}
],
[
"*",
{
"password_hash_b64" : "*",
"password_salt_b64" : "*",
"allowed_apis" : ["database_api", "network_broadcast_api", "history_api"]
}
]
]
}
config.ini
# JSON file specifying API permissions
api-access = "api-access.json"
The Resulting Error
19917ms th_a db_management.cpp:99 reindex ] Done reindexing, elapsed time: 4018.37112100000013015 sec
19957ms th_a application.cpp:480 startup ] 11 eof_exception: End Of File
unexpected end of file
{}
th_a json.cpp:430 variant_from_stream
19957ms th_a application.cpp:1024 startup ] 11 eof_exception: End Of File
unexpected end of file
{}
th_a json.cpp:430 variant_from_stream
rethrow
{}
th_a application.cpp:480 startup
19958ms th_a main.cpp:195 main ] Exiting with error:
11 eof_exception: End Of File
unexpected end of file
{}
th_a json.cpp:430 variant_from_stream
rethrow
{}
th_a application.cpp:480 startup
i reproduced the exact same error with no api-access.json created so the problem is the node can't find the file. solved it by creating file exactly as: http://docs.bitshares.eu/api/access.html and placing at the same folder as config.ini.
please make sure your api-access.json is located in the same directory as config.ini or you can use i think full path.
i am pretty sure the problem is around file location. hope it helps.
The issue is that the api-access.json file are not assumed to be in the same folder as the config.ini file. The code assumes to find this in the same space as the executable file.
So when I specified api-access = "api-access.json" and placed it in the same folder (witness_node_data_dir) I got this error.
Placing it in the root folder does not throw this error, but nothing specifies that the access json has been read and understood.
On a side note, it seems that it doesn't matter if the filename is inside quotes or not.
I can confirm that using a full path will work, because I am using this feature this way. I'm not sure where the file is designed to be, or how others are using it, so don't know whether changing the behavior or "fix" it will break any existed 3rd-party applications.
i added a log to the startup when api-access is present in the config.ini or the command line:
https://github.com/bitshares/bitshares-core/pull/332
also sent pull request to update the documentation encouraging the use of full into the documentation: https://github.com/BitSharesEurope/docs.bitshares.eu/pull/12
patch was merged, please check https://github.com/bitshares/bitshares-core/pull/332
issue will be closed in 24 hs if there is no objections.
Most helpful comment
patch was merged, please check https://github.com/bitshares/bitshares-core/pull/332
issue will be closed in 24 hs if there is no objections.