Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worked examples "FlowclientConnectionError: User claims verification failed" #2108

Closed
oballinger opened this issue Mar 12, 2020 · 4 comments · Fixed by #2121
Closed

Worked examples "FlowclientConnectionError: User claims verification failed" #2108

oballinger opened this issue Mar 12, 2020 · 4 comments · Fixed by #2121
Labels
bug Something isn't working FlowAuth Issues related to FlowAuth permissions

Comments

@oballinger
Copy link

Hi all,

I've been testing out the worked examples, but i keep getting the following error "FlowclientConnectionError: User claims verification failed" when trying execute flowclient.get_results()

I've created a FlowAPI access token and set it in place of TOKEN, as specified in the Jupyter notebook. Any help would be much appreciated! here is the code that is returning the error:

import flowclient
import os
import numpy as np
import geopandas as gpd
import mapboxgl
from mapboxgl.utils import create_color_stops

conn = flowclient.connect(
    url=os.getenv("FLOWAPI_URL", "http://localhost:9090"),
    token=TOKEN,
    ssl_certificate=os.getenv("SSL_CERTIFICATE_FILE"),
)
query_spec = flowclient.total_network_objects(
    start_date="2016-01-01",
    end_date="2016-01-08",
    aggregation_unit="admin3",
    total_by="month",
)
query_spec

towers_per_admin3 = flowclient.get_result(connection=conn, query=query_spec)

here is the error itself:


FlowclientConnectionErrorTraceback (most recent call last)
<ipython-input-12-d5a37a015dee> in <module>
----> 1 towers_per_admin3 = flowclient.get_result(connection=conn, query=query_spec)
      2 towers_per_admin3.head()

/opt/conda/lib/python3.7/site-packages/flowclient/client.py in get_result(connection, query)
    447     """
    448     return get_result_by_query_id(
--> 449         connection=connection, query_id=run_query(connection=connection, query=query)
    450     )
    451 

/opt/conda/lib/python3.7/site-packages/flowclient/client.py in run_query(connection, query)
    548         f"Requesting run of {query} at {connection.url}/api/{connection.api_version}"
    549     )
--> 550     r = connection.post_json(route="run", data=query)
    551     if r.status_code == 202:
    552         query_id = r.headers["Location"].split("/").pop()

/opt/conda/lib/python3.7/site-packages/flowclient/client.py in post_json(self, route, data)
    177             except ValueError:
    178                 error_msg = "Unknown access denied error"
--> 179             raise FlowclientConnectionError(error_msg)
    180         else:
    181             try:

FlowclientConnectionError: User claims verification failed
@jc-harrison
Copy link
Member

Hmm, I can confirm I get the same error (with a token that should be valid). We recently made a change to the way the token validation works, and it looks like something's not quite working. I'll look into it.

@jc-harrison jc-harrison added bug Something isn't working FlowAPI Issues related to the FlowKit API permissions labels Mar 12, 2020
@jc-harrison
Copy link
Member

The root of this problem is that FlowAuth adds a newline to the end of each scope string, which FlowAPI isn't expecting.

@jc-harrison jc-harrison added FlowAuth Issues related to FlowAuth and removed FlowAPI Issues related to the FlowKit API labels Mar 12, 2020
@oballinger
Copy link
Author

oballinger commented Mar 12, 2020

I've only started using flowkit in the past day so i don't know if this is regular behaviour but the setup for the test data on terminal also throws a flowapi token warning:

Ollies-MacBook-Pro-2:~ ollieballinger$ bash <(curl -s https://raw.githubusercontent.com/Flowminder/FlowKit/master/quick_start.sh)
Starting containers (this may take a few minutes)
Existing containers are running and will be replaced. Are you sure? [y/N]? y
WARNING: The AUTOFLOW_DB_PASSWORD variable is not set. Defaulting to a blank string.
WARNING: The FLOWAPI_TOKEN variable is not set. Defaulting to a blank string.
Pulling flowdb                   ... done
Pulling flowmachine_query_locker ... done
Pulling flowmachine              ... done
Pulling flowauth                 ... done
Pulling flowapi                  ... done
WARNING: The AUTOFLOW_DB_PASSWORD variable is not set. Defaulting to a blank string.
WARNING: The FLOWAPI_TOKEN variable is not set. Defaulting to a blank string.
WARNING: The Docker Engine you're using is running in swarm mode.

@jc-harrison
Copy link
Member

Ah, yes, that's not a problem. The FLOWAPI_TOKEN variable isn't required for the containers started in the quick start setup.

@greenape greenape mentioned this issue Mar 13, 2020
8 tasks
@mergify mergify bot closed this as completed in #2121 Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working FlowAuth Issues related to FlowAuth permissions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants