› Forums › OCP Community Discussion Forum › Where can I get OCP OCP API user/key
- This topic has 9 replies, 2 voices, and was last updated 2 years, 8 months ago by
codingadvocate.
-
AuthorPosts
-
-
January 19, 2021 at 3:15 pm #417
Shwetanjali
ParticipantI am trying to set up OCP admin module. I am following the steps from the link https://github.com/opencontentplatform/admin-console
However, I cannot figure out where can I find API user/key that are to be updated in the ocpSettings.json file. -
January 19, 2021 at 3:27 pm #420
codingadvocate
ParticipantThe API user/key are generated when you install OCP.
For reference, about half way through the “Installing OCP” section on the install page (https://www.opencontentplatform.org/install), you run platformConfig.py. That’s where the base API user/key are created. You can certainly create more, to extend to different external API users, after installing OCP. This can be done either through the admin console (which you’re trying to setup), or through an API call directly.
-
January 21, 2021 at 9:50 pm #422
Shwetanjali
ParticipantThanks for responding to my query. I followed the steps mentioned in the install page. However, when I try to run python D:\Software\openContentPlatform\framework\lib\platformConfig.py on cmd, I get the error-[Errno 2] No such file or directory: ‘D:\\\\Software\\\\openContentPlatform\\\\conf\\\\databaseSettings.json’\n”]
Could you please help me in resolving this error. The Kafka and postgres are also installed. -
January 21, 2021 at 9:59 pm #424
codingadvocate
ParticipantHappy to help. I’m assuming that is the path where you put it, right?
You mentioned you are trying to run that on cmd (assuming cmd.exe), and I believe the sample commands were shown for a PowerShell session. Either should work. But you may need to double quote the command arguments. Maybe something like:
python “D:\Software\openContentPlatform\framework\lib\platformConfig.py”
-
January 22, 2021 at 3:26 pm #425
Shwetanjali
ParticipantHi
I was able to install OCP yesterday by running command- [python D:\Software\openContentPlatform\framework\lib\platformConfig.py] on Anaconda prompt. I followed steps on the install page-(https://www.opencontentplatform.org/install/). I was asked to enter User, Owner and API key and then for some access criteria, to which I gave ‘1’ for all three access permissions. After that the message was something like- server has started and few more lines.Today I tried to install admin console after updating “apiUser” and “apiKey” in ocpSettings.json, but got error-
Checking browser emulation setting in registry
Key already found with value: (11001, 4). Leaving key unchanged.
Exception in main: [‘Traceback (most recent call last):\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\urllib3\\connection.py”, line 159, in _new_conn\n (self._dns_host, self.port), self.timeout, **extra_kw)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\urllib3\\util\\connection.py”, line 80, in create_connection\n raise err\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\urllib3\\util\\connection.py”, line 70, in create_connection\n sock.connect(sa)\n’, ‘ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it\n’, ‘\nDuring handling of the above exception, another exception occurred:\n\n’, ‘Traceback (most recent call last):\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\urllib3\\connectionpool.py”, line 600, in urlopen\n chunked=chunked)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\urllib3\\connectionpool.py”, line 354, in _make_request\n conn.request(method, url, **httplib_request_kw)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\http\\client.py”, line 1244, in request\n self._send_request(method, url, body, headers, encode_chunked)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\http\\client.py”, line 1290, in _send_request\n self.endheaders(body, encode_chunked=encode_chunked)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\http\\client.py”, line 1239, in endheaders\n self._send_output(message_body, encode_chunked=encode_chunked)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\http\\client.py”, line 1026, in _send_output\n self.send(msg)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\http\\client.py”, line 966, in send\n self.connect()\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\urllib3\\connection.py”, line 181, in connect\n conn = self._new_conn()\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\urllib3\\connection.py”, line 168, in _new_conn\n self, “Failed to establish a new connection: %s” % e)\n’, ‘urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000001A51F2DCA88>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it\n’, ‘\nDuring handling of the above exception, another exception occurred:\n\n’, ‘Traceback (most recent call last):\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\requests\\adapters.py”, line 449, in send\n timeout=timeout\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\urllib3\\connectionpool.py”, line 638, in urlopen\n _stacktrace=sys.exc_info()[2])\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\urllib3\\util\\retry.py”, line 399, in increment\n raise MaxRetryError(_pool, url, error or ResponseError(cause))\n’, “urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=’localhost’, port=52707): Max retries exceeded with url: /ocp/tool/count/IpAddress (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0x000001A51F2DCA88>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it’))\n”, ‘\nDuring handling of the above exception, another exception occurred:\n\n’, ‘Traceback (most recent call last):\n’, ‘ File “D:\\admin-console-2.1\\admin-console-2.1\\admin-console\\lib\\main.py”, line 543, in main\n restApi = ocpRestAPI.RestAPI(settings[\’restEndpoint\’], settings[\’restProtocol\’], settings[\’restPort\’], settings[\’restPath\’], settings[\’apiUser\’], settings[\’apiKey\’], verify)\n’, ‘ File “D:\\admin-console-2.1\\admin-console-2.1\\admin-console\\lib\\ocpRestAPI.py”, line 25, in __init__\n self.establishConnection()\n’, ‘ File “D:\\admin-console-2.1\\admin-console-2.1\\admin-console\\lib\\ocpRestAPI.py”, line 36, in establishConnection\n apiResponse = requests.get(testUrl, data=payloadAsString, headers=self.header, verify=self.verify)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\requests\\api.py”, line 75, in get\n return request(\’get\’, url, params=params, **kwargs)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\requests\\api.py”, line 60, in request\n return session.request(method=method, url=url, **kwargs)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\requests\\sessions.py”, line 533, in request\n resp = self.send(prep, **send_kwargs)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\requests\\sessions.py”, line 646, in send\n r = adapter.send(request, **kwargs)\n’, ‘ File “C:\\Users\\sdubey\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\requests\\adapters.py”, line 516, in send\n raise ConnectionError(e, request=request)\n’, “requests.exceptions.ConnectionError: HTTPConnectionPool(host=’localhost’, port=52707): Max retries exceeded with url: /ocp/tool/count/IpAddress (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0x000001A51F2DCA88>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it’))\n”]So my question is, do I need to recreate user and apikey to install the admin console or I can use the same which I created yesterday while installing OCP? If I can use the same, then what am I doing wrong because somehow I cannot install admin console. Although I tried creating user and apikey again today but the cmd exits after it takes input for owner/apikey/access criteria and throws a message “Loading Packages…”
-
January 22, 2021 at 3:55 pm #427
codingadvocate
ParticipantHello again.
In short, the admin console isn’t able to talk to the OCP API. This all depends on how you setup OCP. The error is saying it can’t connect to ‘localhost’. Troubleshooting suggestions follow.
First, make sure OCP is running (python openContentPlatform.py) either on the command line or as a service/daemon – before trying to use the admin console. From the error, it looks like you’re running on Windows. Here’s what it should look like when the connection works:
> python .\adminConsole.py
Checking browser emulation setting in registry
Key already found with value: (11001, 4). Leaving key unchanged.
<now a window opens with the admin console>You can use a 3rd party REST API browser (e.g. Insomnia, Postman), to verify the connection to the OCP API. The admin console does the same thing those browsers would to… communicating to the OCP REST API.
You mentioned updating the ocpSettings.json file with a valid apiUser and apiKey. Great. Now make sure the other ocpSettings match what you provided when you configured OCP. To do this, in the admin console directory, open ./conf/ocpSettings.json… and in the OCP directory, open ./conf/globalSettings.json. Go through the admin console settings and make sure they match what you configured for the OCP setup. The values for the following mapping should match:
[admin console setting] == [OCP globalSetting]
“restEndpoint” == “apiIpAddress”
“restProtocol” == “transportType”
“restPort” == “apiServicePort”
“restPath” == “apiContextRoot”If you setup SSL, you need a cert (ocpCertificateFile). Etc.
-
January 24, 2021 at 8:40 pm #428
Shwetanjali
ParticipantHello,
Thanks for the response.
As you mentioned, I have checked the settings in ./conf/ocpSettings.json (admin console directory) and ./conf/globalSettings.json(OCP directory) and these match.
When I run the command- > python .\adminConsole.py
The output is-
Checking browser emulation setting in registry
Key already found with value: (11001, 4). Leaving key unchanged.
Then instead of opening up the admin console, I get the error as mentioned above. -
January 24, 2021 at 8:57 pm #430
codingadvocate
ParticipantThe error you showed before suggested either OCP was not running, or OCP was configured with a different set of settings. Specifically, the Python requests library couldn’t connect to localhost:52707.
Is OCP running, when you attempt the admin client connection? If so, did you try to use a 3rd party REST API browser (Insomnia, Postman, etc) instead of the admin console, to verify the connection to the OCP API?
The previous error showed the connection was being made to localhost. If that’s the case, make sure you run the admin console on the same server as OCP (for the loopback address to work). If you have it running on another machine, then make sure the REST endpoint <server_name_or_ip_address:52707> is reachable… ensure no network or software firewall rules or ACLs are blocking it.
-
January 28, 2021 at 2:52 pm #431
Shwetanjali
ParticipantHi,
Thanks for your help, I could install OCP server and also admin on my local laptop. Also, I would like to inform you, that I had installed Source code zip file for OCP from https://github.com/opencontentplatform/ocp/releases/tag/v2.1 and I got a syntax error in file- .\openContentPlatform\framework\database\initializeDatabase.py. I believe it was between lines 232- 235, a comma was missing between the dictionary keys.
I have an another issue now :P. I am trying to install OCP on one of my organization’s server. I have followed exact same steps as I did while installing OCP on my local laptop. After entering all the details for database server-
databaseServer [IP]: IP
databasePort [5432]: 5432
databaseName [postgres]: postgres
databaseUser [postgres]: postgres
databasePassword:
Retype password:
I get this error- server.Exception in configureDatabase: (psycopg2.OperationalError) could not translate host name “IP” to address: Unknown host
(Background on this error at: http://sqlalche.me/e/13/e3q8)Could you please help me resolve it.
-
January 28, 2021 at 2:53 pm #433
codingadvocate
ParticipantAwesome. Good to hear you got it working on your laptop.
And thanks for the syntax note on initializeDatabase.py. It must have been fixed over the last few months, since I just checked and it’s not an issue in the current mainline (master branch). But we are due to roll another source drop through a testing and release cycle soon, for an updated “release” package.
Regarding the new question on the Postgres connection, please start a new discussion thread on that since this one has a couple topics covered already.
And, I’m assuming you used an actual IP Address for the database server. Meaning, if you look at your ./conf/databaseSettings.json file, you would see a line like this:
“databaseServer”:”10.11.12.13″
and not:
“databaseServer”:”IP”In the mean time, I can look to see if we’ve hit that before.
-
-
AuthorPosts
- You must be logged in to reply to this topic.