Fix oauth revoke token
This commit is contained in:
1 parent
3a4feb9533
commit
9248b19db5
5 files changed
+24
-24
No files matched your search
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- A bug when invalidating tokens
|
||||||
|
|
||||||
## [0.42.1] - 2025-10-04
|
## [0.42.1] - 2025-10-04
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -772,12 +772,8 @@ namespace InnertubeService
|
|||||||
return false
|
return false
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function AuthRevokeAccessToken(accessToken as object, cancellation = invalid as object) as boolean
|
function AuthRevokeToken(token as string, cancellation = invalid as object) as boolean
|
||||||
if not IsAssociativeArray(accessToken)
|
return Innertube.RevokeToken(token, cancellation)
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
return Innertube.RevokeAccessToken(accessToken["accessToken"], cancellation)
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function AuthListAccounts(accessToken as string, cancellation = invalid as object) as object
|
function AuthListAccounts(accessToken as string, cancellation = invalid as object) as object
|
||||||
|
|||||||
@@ -183,9 +183,10 @@ namespace Innertube
|
|||||||
return responseData
|
return responseData
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function RevokeAccessToken(accessToken as string, cancellation = invalid as dynamic) as boolean
|
function RevokeToken(token as string, cancellation = invalid as dynamic) as boolean
|
||||||
request = HttpClient.Post("https://www.youtube.com/o/oauth2/revoke", "")
|
request = HttpClient.PostJson("https://www.youtube.com/o/oauth2/revoke", {
|
||||||
request.QueryParam("token", accessToken)
|
"token": token
|
||||||
|
})
|
||||||
request.Cancellation(cancellation)
|
request.Cancellation(cancellation)
|
||||||
response = request.Await()
|
response = request.Await()
|
||||||
success = response.IsSuccess()
|
success = response.IsSuccess()
|
||||||
|
|||||||
+7
-10
@@ -10,22 +10,19 @@ function ExecuteJob() as void
|
|||||||
service = new Invidious.InvidiousService(invidiousNode)
|
service = new Invidious.InvidiousService(invidiousNode)
|
||||||
|
|
||||||
for each profileNode in profileContentNodes
|
for each profileNode in profileContentNodes
|
||||||
|
' Refresh token is for Innertube
|
||||||
|
token = profileNode.refreshToken
|
||||||
|
if StringUtils.IsNullOrEmpty(token)
|
||||||
|
token = profileNode.accessToken
|
||||||
|
end if
|
||||||
|
|
||||||
authToken = {
|
authToken = {
|
||||||
instance: profileNode.serverUrl
|
instance: profileNode.serverUrl
|
||||||
token: profileNode.accessToken
|
token: token
|
||||||
}
|
}
|
||||||
response = service.UnregisterToken(authToken)
|
response = service.UnregisterToken(authToken)
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
LogWarn(`Failed to unregister token: ${response.ErrorMessage()}`)
|
LogWarn(`Failed to unregister token: ${response.ErrorMessage()}`)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
refreshToken = profileNode.refreshToken
|
|
||||||
if not StringUtils.IsNullOrEmpty(refreshToken)
|
|
||||||
authToken.token = refreshToken
|
|
||||||
response = service.UnregisterToken(authToken)
|
|
||||||
if not response.IsSuccess()
|
|
||||||
LogWarn(`Failed to unregister refresh token: ${response.ErrorMessage()}`)
|
|
||||||
end if
|
|
||||||
end if
|
|
||||||
end for
|
end for
|
||||||
end function
|
end function
|
||||||
+5
-5
@@ -29,19 +29,19 @@ namespace Http
|
|||||||
request = context.request
|
request = context.request
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
accessToken = request.body
|
token = request.body
|
||||||
|
|
||||||
if StringUtils.IsNullOrEmpty(accessToken)
|
if StringUtils.IsNullOrEmpty(token)
|
||||||
response.Json({
|
response.Json({
|
||||||
"error": "Missing 'accessToken' body parameter"
|
"error": "Missing 'token' body parameter"
|
||||||
})
|
})
|
||||||
response.http_code = 400
|
response.http_code = 400
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if not InnertubeService.AuthRevokeAccessToken({ "accessToken": accessToken })
|
if not InnertubeService.AuthRevokeToken(token)
|
||||||
response.Json({
|
response.Json({
|
||||||
"error": "Failed to unregister token"
|
"error": "Failed to revoke token"
|
||||||
})
|
})
|
||||||
response.http_code = 500
|
response.http_code = 500
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in new issue
Block a user