|
1 | 1 | import Foundation |
2 | 2 |
|
3 | | -public protocol AuthAPIv1 { |
4 | | - |
| 3 | +public protocol OAuth11aAPI { |
5 | 4 | /// https://developer.twitter.com/en/docs/authentication/api-reference/request_token |
6 | 5 | func postOAuthRequestTokenData( |
7 | 6 | _ request: PostOAuthRequestTokenRequestV1 |
@@ -32,29 +31,9 @@ public protocol AuthAPIv1 { |
32 | 31 | func postInvalidateAccessToken( |
33 | 32 | _ request: PostOAuthInvalidateTokenRequestV1 |
34 | 33 | ) -> TwitterAPISessionJSONTask |
35 | | - |
36 | | - /// https://developer.twitter.com/en/docs/authentication/api-reference/token |
37 | | - func postOAuth2BearerTokenData( |
38 | | - _ request: PostOAuth2TokenRequestV1 |
39 | | - ) -> TwitterAPISessionDataTask |
40 | | - |
41 | | - /// https://developer.twitter.com/en/docs/authentication/api-reference/token |
42 | | - func postOAuth2BearerToken( |
43 | | - _ request: PostOAuth2TokenRequestV1 |
44 | | - ) -> TwitterAPISessionSpecializedTask<TwitterOAuth2BearerToken> |
45 | | - |
46 | | - /// https://developer.twitter.com/en/docs/authentication/api-reference/invalidate_bearer_token |
47 | | - /// |
48 | | - ///May not work. {"errors":[{"code":348,"message":"Client application is not permitted to to invalidate this token."}]} |
49 | | - /// https://twittercommunity.com/t/oauth2-invalidate-token-not-working-for-app-only-authentication-tokens/133108 |
50 | | - /// https://twittercommunity.com/t/invalidate-bearer-client-application-not-permitted/162761 |
51 | | - func postInvalidateOAuth2BearerToken( |
52 | | - _ request: PostOAuth2InvalidateTokenRequestV1 |
53 | | - ) -> TwitterAPISessionJSONTask |
54 | 34 | } |
55 | 35 |
|
56 | | -extension TwitterAPIKit.TwitterAPIImplV1: AuthAPIv1 { |
57 | | - |
| 36 | +extension TwitterAPIKit.TwitterAuthAPIImpl: OAuth11aAPI { |
58 | 37 | public func postOAuthRequestTokenData( |
59 | 38 | _ request: PostOAuthRequestTokenRequestV1 |
60 | 39 | ) -> TwitterAPISessionDataTask { |
@@ -110,36 +89,4 @@ extension TwitterAPIKit.TwitterAPIImplV1: AuthAPIv1 { |
110 | 89 | ) -> TwitterAPISessionJSONTask { |
111 | 90 | return session.send(request) |
112 | 91 | } |
113 | | - |
114 | | - public func postOAuth2BearerTokenData( |
115 | | - _ request: PostOAuth2TokenRequestV1 |
116 | | - ) -> TwitterAPISessionDataTask { |
117 | | - return session.send(request) |
118 | | - } |
119 | | - |
120 | | - func postOAuth2BearerToken( |
121 | | - _ request: PostOAuth2TokenRequestV1 |
122 | | - ) -> TwitterAPISessionSpecializedTask<TwitterOAuth2BearerToken> { |
123 | | - return session.send(request) |
124 | | - .specialized { data in |
125 | | - do { |
126 | | - guard let token = try TwitterOAuth2BearerToken(jsonData: data) else { |
127 | | - throw TwitterAPIKitError.responseSerializeFailed( |
128 | | - reason: .cannotConvert(data: data, toTypeName: "TwitterOAuth2BearerToken") |
129 | | - ) |
130 | | - } |
131 | | - return token |
132 | | - } catch let error { |
133 | | - throw TwitterAPIKitError.responseSerializeFailed( |
134 | | - reason: .jsonSerializationFailed(error: error) |
135 | | - ) |
136 | | - } |
137 | | - } |
138 | | - } |
139 | | - |
140 | | - public func postInvalidateOAuth2BearerToken( |
141 | | - _ request: PostOAuth2InvalidateTokenRequestV1 |
142 | | - ) -> TwitterAPISessionJSONTask { |
143 | | - return session.send(request) |
144 | | - } |
145 | 92 | } |
0 commit comments