[GH-ISSUE #235] Is there any way to do logout with SFSafariViewController? #133

Closed
opened 2026-03-03 16:45:58 +03:00 by kerem · 7 comments
Owner

Originally created by @dasoga on GitHub (Jun 14, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/235

I'm trying to do logout user from my server.
With url like: "http://auth.mydomain.com/logout

I'm using Safari View controller
Somebody knows how can I do logout through OAuthSwift?.
Thanks!

Originally created by @dasoga on GitHub (Jun 14, 2016). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/235 I'm trying to do logout user from my server. With url like: "http://auth.mydomain.com/logout I'm using Safari View controller Somebody knows how can I do logout through OAuthSwift?. Thanks!
kerem 2026-03-03 16:45:58 +03:00
Author
Owner

@phimage commented on GitHub (Jun 16, 2016):

According to the docs: SFSafariViewController shares cookies and other website data with Safari and because it runs outside your app's process (for security reasons) I think you cannot modify it's state from inside your app
(Without SFSafariViewController ie. webkit view we remove the cookies)

Maybe we could present the SFSafariViewController with logout page for the specific provider, for instance http://github.com/logout or your url
Just open it SFSafariViewController (url: ...) and let user logout

<!-- gh-comment-id:226457350 --> @phimage commented on GitHub (Jun 16, 2016): According to the docs: SFSafariViewController shares cookies and other website data with Safari and because it runs outside your app's process (for security reasons) I think you cannot modify it's state from inside your app (Without SFSafariViewController ie. webkit view we remove the cookies) Maybe we could present the SFSafariViewController with logout page for the specific provider, for instance http://github.com/logout or your url Just open it SFSafariViewController (url: ...) and let user logout
Author
Owner

@dasoga commented on GitHub (Jun 16, 2016):

My problem is when I open SFSafariViewController with my url "http://auth.mydomain.com/logout" whit this code:

    for key in Array(NSUserDefaults.standardUserDefaults().dictionaryRepresentation().keys) {
        print(key)
        NSUserDefaults.standardUserDefaults().removeObjectForKey(key)
    }
    let urlString = "http://auth.dubalu.com/logout"
    if let url = NSURL(string: urlString) {
        let vc = SFSafariViewController(URL: url, entersReaderIfAvailable: true)
        vc.delegate = self
        presentViewController(vc, animated: true, completion: { 
            self.goToLoginView()
        })
    }

I'm clearing all cache and in completion I'm going to my login view controller, but SFSafariViewController is still in the stack of view controller.

Someone who knows if is another way to do this?

Really thanks!

<!-- gh-comment-id:226512475 --> @dasoga commented on GitHub (Jun 16, 2016): My problem is when I open SFSafariViewController with my url "http://auth.mydomain.com/logout" whit this code: ``` for key in Array(NSUserDefaults.standardUserDefaults().dictionaryRepresentation().keys) { print(key) NSUserDefaults.standardUserDefaults().removeObjectForKey(key) } let urlString = "http://auth.dubalu.com/logout" if let url = NSURL(string: urlString) { let vc = SFSafariViewController(URL: url, entersReaderIfAvailable: true) vc.delegate = self presentViewController(vc, animated: true, completion: { self.goToLoginView() }) } ``` I'm clearing all cache and in completion I'm going to my login view controller, but SFSafariViewController is still in the stack of view controller. Someone who knows if is another way to do this? Really thanks!
Author
Owner

@dasoga commented on GitHub (Jun 16, 2016):

@phimage actually that's works good, but the SFSafariViewController is still in the stack of view controllers.

<!-- gh-comment-id:226513097 --> @dasoga commented on GitHub (Jun 16, 2016): @phimage actually that's works good, but the SFSafariViewController is still in the stack of view controllers.
Author
Owner

@phimage commented on GitHub (Jun 16, 2016):

you have an error message which specify that? (view already in stack..) ie. the controller is not well dismissed

<!-- gh-comment-id:226581195 --> @phimage commented on GitHub (Jun 16, 2016): you have an error message which specify that? (view already in stack..) ie. the controller is not well dismissed
Author
Owner

@dasoga commented on GitHub (Jun 16, 2016):

@phimage sorry, yes that is the problem, the SFSafariViewController is not well dismissed.

<!-- gh-comment-id:226630549 --> @dasoga commented on GitHub (Jun 16, 2016): @phimage sorry, yes that is the problem, the SFSafariViewController is not well dismissed.
Author
Owner

@phimage commented on GitHub (Jul 7, 2016):

@dasoga If you have an error message please post it (google search with this message could help me to understand)

In the past I have some issue with controller not well dismissed, dispatch queue problem. So I use a library like https://github.com/kodlian/Eki to dispatch some code into main (or background) queue

<!-- gh-comment-id:230993336 --> @phimage commented on GitHub (Jul 7, 2016): @dasoga If you have an error message please post it (google search with this message could help me to understand) In the past I have some issue with controller not well dismissed, dispatch queue problem. So I use a library like https://github.com/kodlian/Eki to dispatch some code into main (or background) queue
Author
Owner

@phimage commented on GitHub (Aug 8, 2016):

https://github.com/OAuthSwift/OAuthSwift/wiki/Logout

<!-- gh-comment-id:238197613 --> @phimage commented on GitHub (Aug 8, 2016): https://github.com/OAuthSwift/OAuthSwift/wiki/Logout
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#133
No description provided.