AppAuth-iOS icon indicating copy to clipboard operation
AppAuth-iOS copied to clipboard

Is there a way to clear the credentials stored by AppAuth in iOS

Open arvinthmani opened this issue 4 years ago • 10 comments

I am using AppAuth 1.3.0 lib for authenticating my App. It popup safari viewcontroller and after entering the credentials, i am logging in. But after logout when i tried to login with different credentials, it is login in with same old credentials. Until i close and open the App, its using the same credentials. How to clear the old credentials which is stored from AppAuth lib?

arvinthmani avatar Jun 10 '20 14:06 arvinthmani

Please help me to resolve this issue

arvinthmani avatar Jun 10 '20 17:06 arvinthmani

Please help me to resolve this issue

Any solution??

I've tried clean cookies: HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)

And Clean records: fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in records.forEach { record in self.removeData(ofTypes: record.dataTypes, for: [record], completionHandler: {}) print("[WebCacheCleaner] Record \(record.displayName) deleted") } }

But without success.

sidneivl avatar Jun 17 '20 17:06 sidneivl

Please help me to resolve this issue

Any solution??

I've tried clean cookies: HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)

And Clean records: fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in records.forEach { record in self.removeData(ofTypes: record.dataTypes, for: [record], completionHandler: {}) print("[WebCacheCleaner] Record \(record.displayName) deleted") } }

But without success.

No i didn't get solution

arvinthmani avatar Jun 18 '20 07:06 arvinthmani

@arvinthmani I got a solution.

In my case I'm using endpoint session with parameter "id_token_hint" (accessToken set on parameter).

Call endPointSession endpoint using self.entityAuthState.authState?.lastAuthorizationResponse.request.configuration.discoveryDocument?.endSessionEndpoint

You need check with your back end if need send any specific parameter or I just call this end point is enough.

sidneivl avatar Jun 18 '20 11:06 sidneivl

AppAuth uses ASWebAuthenticationSession which shares cookies with Safari (except for session cookies). To log out of the browser session, the IdP needs to delete that cookie (e.g. through a user initiated logout action, or through support of the OIDC Logout protocol).

These credentials are not stored in AppAuth. As far as AppAuth is concerned, once you delete the OIDAuthState object all grants are gone.

WilliamDenniss avatar Jun 24 '20 22:06 WilliamDenniss

Hello @WilliamDenniss , had you disable SafariViewController cookies? because when we do first time sign-in then sign out. again sign in then it is not asking different credentials. it is going for auto login. when we remove our app from cache the again open our app then sign in, that time we can login with different credential. could you please help me for that? and have you config SafariViewcontroller like this: let config = SFSafariViewController.Configuration() config.entersReaderIfAvailable = true

SomuYadav avatar Jul 21 '20 12:07 SomuYadav

Additional paramters : ["prompt": "login"]

adozenlines avatar Nov 08 '20 18:11 adozenlines

@adozenlines right answer

fukemy avatar Feb 18 '21 09:02 fukemy

AppAuth uses ASWebAuthenticationSession which shares cookies with Safari (except for session cookies). To log out of the browser session, the IdP needs to delete that cookie (e.g. through a user initiated logout action, or through support of the OIDC Logout protocol).

These credentials are not stored in AppAuth. As far as AppAuth is concerned, once you delete the OIDAuthState object all grants are gone.

@WilliamDenniss - what are your thoughts on defaulting the prefersEphemeralWebBrowserSession to true for ASWebAuthenticationSession sessions?

as per: https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/3237231-prefersephemeralwebbrowsersessio

https://developer.apple.com/documentation/authenticationservices/authenticating_a_user_through_a_web_service

adriancb avatar Jan 25 '22 02:01 adriancb

@adozenlines didn't work by additionalParameters: ["prompt": "login"] ? Anyone solve this issue?

tiwari1amrit avatar Apr 18 '23 03:04 tiwari1amrit