gentle-lifeguard-88494
02/01/2023, 1:06 AM# query = """mutation {
# createAccessToken(input: {type: PERSONAL, actorUrn: "urn:li:corpuser:datahub", duration: NO_EXPIRY, name: "my personal token"}) {
# accessToken
# metadata {
# id
# name
# description
# }
# }
# }
# """
Then I went ahead and added it to my recipe:
source:
type: postgres
config:
# Coordinates
host_port: localhost:5432
database: andreasmartinson
# Credentials
username: ${USERNAME}
password: ${PASSWORD}
# Options
database_alias: postgres
# <https://datahubproject.io/docs/authentication/introducing-metadata-service-authentication/>
sink:
type: "datahub-rest"
config:
server: "<http://localhost:8080>"
token: ${DATAHUB_TOKEN}
I then re-ingested the metadata and passed in the token:
datahub ingest -c config/postgres_datahub_config.dhub.yaml
Then I tried this query:
import requests
query = """query search {
search(input: {type: DATASET, query: "*", start: 0, count: 100}) {
searchResults {
entity {
... on Dataset {
properties {
name
description
}
schemaMetadata {
name
fields {
fieldPath
nativeDataType
}
}
}
}
}
}
}
"""
url = '<http://localhost:9002/api/graphiql>'
r = <http://requests.post|requests.post>(url, json={'query': query})
print(r.status_code)
print(r.text)
I verified that the query worked using the graphql frontend, it's just that I keep getting a 401 permissions error. Could someone help me figure out why I might be getting a permissions error? Feel like I'm probably missing something simple herehundreds-photographer-13496
02/01/2023, 8:57 AMserver: <http://localhost:9002/api/gms>gentle-lifeguard-88494
02/02/2023, 7:47 PMimport requests
import os
import json
datahub_key = os.getenv("DATAHUB_TOKEN")
query = json.dumps({'query':"""
query search {
search(input: {type: DATASET, query: "*", start: 0, count: 100}) {
searchResults {
entity {
... on Dataset {
properties {
name
description
}
schemaMetadata {
name
fields {
fieldPath
nativeDataType
}
}
}
}
}
}
}
"""})
headers = {
'Authorization': f'Bearer {datahub_key}',
'Content-Type': 'application/json'
}
url = '<http://localhost:9002/api/graphql>'
r = <http://requests.post|requests.post>(url, headers=headers, data=query)
print(r.status_code)
print(r.text)