mercedes-benz / disclosure-cli

MIT License
10 stars 2 forks source link

howto get project token #50

Open cforce opened 3 weeks ago

cforce commented 3 weeks ago

Disclosure Portal Only project owners in the Disclosure Portal have the permissions to do these steps. a) Create a new Project in the >Disclosure Portal. Take note of the Unique identifier of the project, you will need it in a moment. b) Create a token. You will need this >token to access your project with the Disclosure-CLI.

How to create such token to authenticate? Is is a Tokenmaster token or is it gas/iamat or embeedded somewhwre is DISCO (where?)

cforce commented 3 weeks ago

found the token, but still does not work to use the token in in a curl


#!/bin/bash

# Environment variable setup
#export DISCO_PROJECT_TOKEN=

# API URL
API_URL="https://production.gorillas.mercedes-benz.com/disco/v1/policyrules/XXXXXXXXXXXXXXXXXXXXXXXXXXX"

# Output file
OUTPUT_FILE="policy_rules_output.json"

# Curl command to get data from the API using OAuth token
curl "$API_URL" \
  -H "accept: application/json, text/plain, */*" \
  -H "Authorization: Bearer $DISCO_PROJECT_TOKEN" \
  -o "$OUTPUT_FILE"

# Check if the request was successful
if [ $? -eq 0 ]; then
  echo "Data successfully written to $OUTPUT_FILE"
else
  echo "Failed to retrieve data"
fi
karlpip commented 3 weeks ago

Try prepending DISCO to the token.

cforce commented 3 weeks ago

Still 404

#!/bin/bash

# Environment variable setup
#export DISCO_PROJECT_TOKEN=

# API URL
API_URL="https://production.gorillas.mercedes-benz.com/disco/v1/policyrules/XXXXXXXXXXXXXXXXXXXXXXXXXXX"

# Output file
OUTPUT_FILE="policy_rules_output.json"

# Curl command to get data from the API using OAuth token
curl "$API_URL" \
  -H "accept: application/json, text/plain, */*" \
  -H "Authorization: Bearer DISCO ${DISCO_PROJECT_TOKEN}" \
  -o "$OUTPUT_FILE"

# Check if the request was successful
if [ $? -eq 0 ]; then
  echo "Data successfully written to $OUTPUT_FILE"
else
  echo "Failed to retrieve data"
fi
karlpip commented 3 weeks ago

There is a space missing between the token value and DISCO string.