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

Sign out without presenting new controller #795

Closed
tarasChernysh opened this issue Oct 10, 2023 · 1 comment
Closed

Sign out without presenting new controller #795

tarasChernysh opened this issue Oct 10, 2023 · 1 comment

Comments

@tarasChernysh
Copy link

tarasChernysh commented Oct 10, 2023

          hello, 
          can we logout user without presenting new controller? 
          Something like this: tap on button and logout without any redirection.

Originally posted by @tarasChernysh in #47 (comment)

@tarasChernysh
Copy link
Author

I archived that making an API request using this params

struct OAuthSignOutRequest {
    let accessToken: String
    let refreshToken: String
    let clientId: String
    let endSessionURL: URL
    
    var urlRequest: URLRequest {
        let headers = [
            "Authorization": "Bearer \(self.accessToken)",
            "Content-Type": "application/x-www-form-urlencoded"
        ]
        var components = URLComponents()
        components.queryItems = [
            .init(name: "client_id", value: self.clientId),
            .init(name: "refresh_token", value: self.refreshToken)
        ]

        var request = URLRequest(url: self.endSessionURL)
        headers.forEach {
            request.setValue($0.value, forHTTPHeaderField: $0.key)
        }
        request.httpMethod = "POST"
        request.httpBody = components.query?.data(using: .utf8)
        return request
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant