Skip to content

TECS-431: Change "Client ID" to "API Project ID" #1

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

Merged
merged 1 commit into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ This is one of

Make sure to save the file.

### `client_id.txt`
### `api_project_id.txt`

In the downloaded `cloud-api-example-code` folder, open `client_id.txt`.
In the downloaded `cloud-api-example-code` folder, open `api_project_id.txt`.

Populate this file with your application ID from Alteryx Analytics Cloud.

Expand All @@ -42,9 +42,9 @@ Populate this file with your application ID from Alteryx Analytics Cloud.

1. You should see your new project in the list of projects. ![Project listing](images/listOfProjects.png)

1. Click on the project and copy the Client ID to your clipboard. ![Copying Client ID](images/copyingClientId.png)
1. Click on the project and copy the API Project ID to your clipboard. ![Copying API Project ID](images/copyingApiProjectId.png)

1. Open the `client_id.txt` file in this repository, and paste in the copied Client ID. Be sure to save the file. ![Client ID file](images/clientIdFile.png)
1. Open the `api_project_id.txt` file in this repository, and paste in the copied API Project ID. Be sure to save the file. ![API Project ID file](images/apiProjectIdFile.png)

### `creds.json`

Expand Down Expand Up @@ -161,7 +161,7 @@ The expected output looks like:
}
```

Ensure that your client ID in `client_id.txt` is present and correct. See instructions above.
Ensure that your API Project ID in `api_project_id.txt` is present and correct. See instructions above.

### `rllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>`

Expand Down
1 change: 1 addition & 0 deletions api_project_id.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Your api project id here
1 change: 0 additions & 1 deletion client_id.txt

This file was deleted.

10 changes: 5 additions & 5 deletions get_workspace.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import fs from 'fs/promises';
* This program prints the current workspace using credentials stored in files
*/

const clientIdFile = 'client_id.txt';
const apiProjectIdFile = 'api_project_id.txt';
const credsFile = 'creds.json'
const aacURLFile = 'aac_url.txt'

async function main() {
const accessToken = await getAccessToken();
const clientId = (await fs.readFile(clientIdFile)).toString().trim();
const apiProjectId = (await fs.readFile(apiProjectIdFile)).toString().trim();
const aacURL = (await fs.readFile(aacURLFile)).toString().trim();
console.log(await getCurrentWorkspace(aacURL, accessToken, clientId));
console.log(await getCurrentWorkspace(aacURL, accessToken, apiProjectId));
}

main();
Expand Down Expand Up @@ -58,12 +58,12 @@ async function getAccessToken() {
/**
* Gets the current workspace, and returns it as an object
*/
async function getCurrentWorkspace(aacURL, accessToken, clientId) {
async function getCurrentWorkspace(aacURL, accessToken, apiProjectId) {

// These headers are necessary in every request to the AAC API
const headers = {
'Authorization': `Bearer ${accessToken}`,
'x-client-id': clientId,
'x-api-project-id': apiProjectId,
'User-Agent': 'myApp', // Describe your application here
}

Expand Down
16 changes: 8 additions & 8 deletions get_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
"""

"""
Get a new Client ID here: https://us1.alteryxcloud.com/cloud-portal/library/alteryx-io
Get a new Api Project ID here: https://us1.alteryxcloud.com/cloud-portal/library/alteryx-io
This uniquely identifies your application
"""
client_id_file = 'client_id.txt'
api_project_id_file = 'api_project_id.txt'
creds_file = 'creds.json'
aac_url_file = 'aac_url.txt'

def main():
with open(client_id_file) as f:
client_id = f.read().rstrip()
with open(api_project_id_file) as f:
api_project_id = f.read().rstrip()
access_token = get_access_token()
with open(aac_url_file) as f:
aac_url = f.read().rstrip()
print(get_current_workspace(aac_url, access_token, client_id))
print(get_current_workspace(aac_url, access_token, api_project_id))

def get_access_token():
"""
Expand Down Expand Up @@ -62,15 +62,15 @@ def get_access_token():

return new_creds['access_token']

def get_current_workspace(aac_url, access_token, client_id):
def get_current_workspace(aac_url, access_token, api_project_id):
"""
Given an access token and client id,
Given an access token and api project id,
Gets the current workspace, and returns it as an object
"""
# These headers are necessary in every request to the AAC API
headers = {
'Authorization': f'Bearer {access_token}',
'x-client-id': client_id,
'x-api-project-id': api_project_id,
'User-Agent': 'my_app', # Descirbe your application here
}

Expand Down
10 changes: 5 additions & 5 deletions get_workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

# Requirements: jq, curl

client_id_file="client_id.txt"
api_project_id_file="api_project_id.txt"
creds_file="creds.json"
aac_url_file="aac_url.txt"

# Main function
main() {
client_id=$(cat $client_id_file | xargs)
api_project_id=$(cat $api_project_id_file | xargs)
access_token=$(get_access_token)
aac_url=$(cat $aac_url_file | xargs)
echo $(get_current_workspace "$access_token" "$client_id" "$aac_url")
echo $(get_current_workspace "$access_token" "$api_project_id" "$aac_url")
}

# Function to get the access token (with refresh logic)
Expand Down Expand Up @@ -49,13 +49,13 @@ get_access_token() {
get_current_workspace() {

access_token="$1"
client_id="$2"
api_project_id="$2"
aac_url="$3"

# Make the request to get the current workspace using curl
response=$(curl -s -X GET "$aac_url/iam/v1/workspaces/current" \
-H "Authorization: Bearer $access_token" \
-H "x-client-id: $client_id" \
-H "x-api-project-id: $api_project_id" \
-H "User-Agent: myApp") # Describe your application here

# Output the response (current workspace)
Expand Down
Binary file added images/apiProjectIdFile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/clientIdFile.png
Binary file not shown.
Binary file added images/copyingApiProjectid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/copyingClientId.png
Binary file not shown.