Hi, is prefect-core API unsecured by default? I am...
# prefect-community
Hi, is prefect-core API unsecured by default? I am trying to create an API token and get cryptic errors about JSON not being able to be parsed? The story is that I am trying to create a local agent by running
prefect agent start
This results in an error complaining about missing an API token.
prefect.utilities.exceptions.AuthorizationError: No agent API token provided.
When I then call
prefect auth create-token -n calypso -s RUNNER
I see the following error:
Copy code
Traceback (most recent call last):
  File "/home/lmuniz/.local/bin/prefect", line 8, in <module>
  File "/home/lmuniz/.local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/lmuniz/.local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/lmuniz/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/lmuniz/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/lmuniz/.local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/lmuniz/.local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/lmuniz/.local/lib/python3.8/site-packages/prefect/cli/auth.py", line 201, in create_token
    output = client.graphql(
  File "/home/lmuniz/.local/lib/python3.8/site-packages/prefect/client/client.py", line 213, in graphql
    result = <http://self.post|self.post>(
  File "/home/lmuniz/.local/lib/python3.8/site-packages/prefect/client/client.py", line 172, in post
    response = self._request(
  File "/home/lmuniz/.local/lib/python3.8/site-packages/prefect/client/client.py", line 334, in _request
    json_resp = response.json()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I have started prefect with the recommended
prefect server start
command and installed prefect with pip3.
Copy code
$prefect diagnostics                                                                                                    
  "config_overrides": {},
  "env_vars": [],
  "system_information": {
    "platform": "Linux-5.4.0-7624-generic-x86_64-with-glibc2.29",
    "prefect_version": "0.12.1",
    "python_version": "3.8.2"
Also: using the Dask executor ( created a local dask cluster)
Copy code
export PREFECT__ENGINE__EXECUTOR__DEFAULT_CLASS="prefect.engine.executors.DaskExecutor"
@Luis Muniz What version of prefect are you on?
Copy code
"prefect_version": "0.12.1",
I opened this bug yesteday
I'm not connecting to prefect cloud
Hmm no secrets? nothing?
I'm trying to run prefect independently, locally, to try to figure it out
just prefect-core
or is it not runnable independently of prefect cloud?
prefect is completely runnable independently. Its how most of my jobs are run..
Try installing version 0,12,0
maybe I need to set up an environment variable to tell it to connect to the local API
I will try that
please try installing
pip install -U prefect==0.12.0
Let me know if that works.
yes, tokens are only for cloud deployments
By the way I have the same behavior with 0.12.0
Still no idea how to run an agent loccally though
OK @itay livni
Copy code
prefect backend server
this was missing to tell my local setup that it is not useing prefec tcloud
after that I can start an agent
But yes: it seems that the prefect-core API is unauthenticated by default
Hi @Luis Muniz - you are confusing the locally served Prefect API with the Cloud API. The open source, locally served API has no authentication built in. The Prefect Cloud API does have authentication via JWT tokens. Your commands are attempting to hit the Prefect Cloud API and are running into errors because you haven’t logged in yet. If you’d like to use the secure API, I suggest logging in (for free) at https://cloud.prefect.io/ but if you want to use your locally hosted one, you should run
prefect backend server
first and avoid all auth-related commands
Yes, it took me some time to realize that, thanks @Chris White. So am I right to think unless you use Prefect cloud you can't have secure access to the API ?
(using just prefect core)
Yup that’s essentially correct - we reserve the authentication layer for our hosted platform