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

APS Logout #1016

Merged
merged 19 commits into from
Jul 26, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1f249e9
revoke public user token
azaleacolburn Jul 1, 2024
47afbbd
added revoke for private user
azaleacolburn Jul 2, 2024
9aac5c2
added private user token revocation
azaleacolburn Jul 2, 2024
82deefb
Merge branch 'dev' of https://github.com/Autodesk/synthesis into colb…
azaleacolburn Jul 11, 2024
3af094e
moved aps logout to fission
azaleacolburn Jul 11, 2024
ec12611
added private user token revoking to fission
azaleacolburn Jul 11, 2024
f162960
fixed url (still doesn't work lol)
azaleacolburn Jul 11, 2024
fa505d6
added doc link
azaleacolburn Jul 11, 2024
65eb06e
Merge branch 'dev' of https://github.com/Autodesk/synthesis into colb…
azaleacolburn Jul 14, 2024
bdd0c08
fixed urlencoding for token revocation
azaleacolburn Jul 14, 2024
f67f467
Merge branch 'dev' of https://github.com/Autodesk/synthesis into colb…
azaleacolburn Jul 15, 2024
ed6c548
Update fission/src/aps/APS.ts
azaleacolburn Jul 17, 2024
dbdbc9f
Update fission/src/aps/APS.ts
azaleacolburn Jul 17, 2024
0f459c1
Merge branch 'dev' of https://github.com/Autodesk/synthesis into colb…
azaleacolburn Jul 17, 2024
08043a4
removed lockfile and removed the early return in aps logout
azaleacolburn Jul 17, 2024
0352957
Merge branch 'colbura/1709/aps-logout' of https://github.com/Autodesk…
azaleacolburn Jul 17, 2024
fdfbfcc
Update fission/src/aps/APS.ts
azaleacolburn Jul 18, 2024
abab679
Merge branch 'dev' of https://github.com/Autodesk/synthesis into colb…
azaleacolburn Jul 24, 2024
c0ad668
update token scope
azaleacolburn Jul 24, 2024
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
33 changes: 32 additions & 1 deletion fission/src/aps/APS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const ENDPOINT_SYNTHESIS_CHALLENGE = `/api/aps/challenge`

const ENDPOINT_AUTODESK_AUTHENTICATION_AUTHORIZE = "https://developer.api.autodesk.com/authentication/v2/authorize"
const ENDPOINT_AUTODESK_AUTHENTICATION_TOKEN = "https://developer.api.autodesk.com/authentication/v2/token"
const ENDPOINT_AUTODESK_REVOKE_TOKEN = "https://developer.api.autodesk.com/authentication/v2/revoke"
const ENDPOINT_AUTODESK_USERINFO = "https://api.userprofile.autodesk.com/userinfo"

export interface APSAuth {
Expand Down Expand Up @@ -122,12 +123,42 @@ class APS {
}

/**
* Logs the user out by setting their auth data to undefined.
* Logs the user out by setting their auth data to undefined and revoking their auth token.
*/
static async logout() {
await this.revokeTokenPublic()
this.auth = undefined
}

/*
* Revokes the users token
*
* The client should be public since we're an spa
* Endpoint documentation:
* https://aps.autodesk.com/en/docs/oauth/v2/reference/http/revoke-POST/
*/
static async revokeTokenPublic(): Promise<boolean> {
const headers = {
"Content-Type": "application/x-www-form-urlencoded",
}
const opts = {
method: "POST",
headers: headers,
body: new URLSearchParams([
["token", this.auth?.access_token],
["token_type_hint", "access_token"],
["client_id", CLIENT_ID],
] as string[][]),
}
const res = await fetch(ENDPOINT_AUTODESK_REVOKE_TOKEN, opts)
if (!res.ok) {
console.log("Failed to revoke auth token:\n")
return false
}
console.log("Revoked auth token")
return true
}

/**
* Prompts the user to sign in, which will retrieve the auth code.
*/
Expand Down
Loading