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

Can't authenticate to prefect cloud #8

Closed
hanscgruber opened this issue Nov 22, 2023 · 2 comments
Closed

Can't authenticate to prefect cloud #8

hanscgruber opened this issue Nov 22, 2023 · 2 comments

Comments

@hanscgruber
Copy link
Contributor

The HTTP.request call is using the prefect api url but does not present a header bearer token to authenticate so it fails:

PREFECT_API_URL
PREFECT_API_KEY
# both present in ENV

using PrefectInterfaces

PrefectAPI()
# PrefectAPI("http://127.0.0.1:4204/api")
ENV["PREFECT_API_URL"]="https://api.prefect.cloud/api/accounts/0e3afxxxxxxxxxx"

ls()
┌ Warning: no connection.
│   api_url = "https://api.prefect.cloud/api/accounts/0e3afxxxxxx"
└ @ PrefectInterfaces ~/.julia/packages/PrefectInterfaces/T1HiK/src/prefectblock/prefectblock.jl:101
HTTP.Exceptions.StatusError(403, "POST", "/api/accounts/0e3xxxxxxx/block_documents/filter", HTTP.Messages.Response:
"""
HTTP/1.1 403 Forbidden
...
{"detail":"Not authenticated"}""")
mahiki added a commit that referenced this issue Nov 27, 2023
Issue #8 prefect api now initializes key; tests pass
@mahiki
Copy link
Owner

mahiki commented Nov 27, 2023

Closed by hans gruber pull request: #11

@mahiki mahiki closed this as completed Nov 27, 2023
@hanscgruber
Copy link
Contributor Author

I'll copy some of the usage notes here that I added to the pull request:

# NOTE: I rotated my api key after accidentally committing it here.
api = PrefectAPI("https://api.prefect.cloud/api/accounts/0e3aff3a-16ab-411f-baed-2982e4c82ebd/workspaces/0cd79ef6-aa52-43f7-8357-0f8dc0ff30ce", "pnu_OOOOOOOOPS");

b = ls(api=api);

b.blocks
13-element Vector{String}:
 "credentialpair/trino-creds"
 "github/cloud"
 "github/ikeloa-tables-cloud"
 "local-file-system/datastore"
 "local-file-system/idioteque"
 "process/idioteque"
 "s3-bucket/datastore"
 "slack-webhook/team-alerts"
 "string/environment"

ab = getblock("credentialpair/trino-creds", api=api)
Dict{String, Any} with 12 entries:
  "block_type_id"             => "94a978e3-6f80-406b-ab19-54ccd8a6ba54"
  "block_type_name"           => "CredentialPair"
...etc

fsblock = PrefectBlock("local-file-system/idioteque");

dump(fsblock2)
PrefectBlock
  blockname: String "local-file-system/idioteque"
  block: LocalFSBlock
    blockname: String "local-file-system/idioteque"
    blocktype: String "local-file-system"
    basepath: String "HOME/prefect-local-deployment/dev"
    read_path: #1 (function of type PrefectInterfaces.var"#1#3"{String})
      basepath: String "HOME/prefect-local-deployment/dev"
    write_path: #2 (function of type PrefectInterfaces.var"#2#4"{String})
      basepath: String "HOME/prefect-local-deployment/dev"

Works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants