forked from openedx-unsupported/edx-app-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LogoutApi.swift
30 lines (25 loc) · 851 Bytes
/
LogoutApi.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// LogoutApi.swift
// edX
//
// Created by Saeed Bashir on 8/11/16.
// Copyright © 2016 edX. All rights reserved.
//
import Foundation
public struct LogoutApi {
private static func invalidateTokenDeserializer(response : HTTPURLResponse) -> Result<()> {
guard response.httpStatusCode.is2xx else {
return Failure()
}
return Success(v: ())
}
public static func invalidateToken(refreshToken: String, clientID: String) -> NetworkRequest<()> {
let body = ["token": refreshToken, "client_id": clientID, "token_type_hint": "refresh_token"]
return NetworkRequest(
method: .POST,
path: "/oauth2/revoke_token/",
body: RequestBody.formEncoded(body),
deserializer: .noContent(invalidateTokenDeserializer)
)
}
}