Skip to content

Commit bd4c214

Browse files
committed
add PostOAuth2RevokeTokenRequestV2
1 parent b90461c commit bd4c214

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

Sources/TwitterAPIKit/AuthAPI/OAuth20API.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public protocol OAuth20API {
4343
func postOAuth2RefreshToken(
4444
_ request: PostOAuth2RefreshTokenRequestV2
4545
) -> TwitterAPISessionSpecializedTask<TwitterOAuth2AccessToken>
46+
47+
func postOAuth2RevokeToken(
48+
_ request: PostOAuth2RevokeTokenRequestV2
49+
) -> TwitterAPISessionDataTask
4650
}
4751

4852
extension TwitterAPIKit.TwitterAuthAPIImpl: OAuth20API {
@@ -112,4 +116,10 @@ extension TwitterAPIKit.TwitterAuthAPIImpl: OAuth20API {
112116
return postOAuth2RefreshTokenData(request)
113117
.specialized { try TwitterOAuth2AccessToken.fromResponse(data: $0) }
114118
}
119+
120+
func postOAuth2RevokeToken(
121+
_ request: PostOAuth2RevokeTokenRequestV2
122+
) -> TwitterAPISessionDataTask {
123+
return session.send(request)
124+
}
115125
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import Foundation
2+
3+
/// https://developer.twitter.com/en/docs/authentication/oauth-2-0/user-access-token
4+
open class PostOAuth2RevokeTokenRequestV2: TwitterAPIRequest {
5+
6+
public let token: String
7+
/// Required for Public Client.
8+
public let clientID: String?
9+
10+
public var method: HTTPMethod {
11+
return .post
12+
}
13+
14+
public var path: String {
15+
return "/2/oauth2/revoke"
16+
}
17+
18+
open var parameters: [String: Any] {
19+
var p = [String: String]()
20+
p["token"] = token
21+
clientID.map { p["client_id"] = $0 }
22+
return p
23+
}
24+
25+
public init(
26+
token: String,
27+
clientID: String? = .none
28+
) {
29+
self.token = token
30+
self.clientID = clientID
31+
}
32+
}

0 commit comments

Comments
 (0)