Closed jcombs-pointblue closed 2 years ago
Has anyoone else tried to figure this out?
This is probably way late, but I found a fix:
oauth2.authConfig.authorizeEmbedded = true
oauth2.authConfig.authorizeContext = UIApplication.shared.windows[0].rootViewController
Not too, late at all! Thanks, hard to believe it was that simple
On Jul 8, 2020, at 18:35, Kevin Li notifications@github.com wrote:
This is probably way late, but I found a fix:
oauth2.authConfig.authorizeEmbedded = true
oauth2.authConfig.authorizeContext = UIApplication.shared.windows[0].rootViewController
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/p2/OAuth2/issues/334#issuecomment-655811434, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB63SQ3Q7YJF7DJSSMPKPATR2T7EFANCNFSM4KSU24UA.
does this package actually support SwiftUI??? I don't see anything about that
The embedded browser shouldn't be used anymore because it technically allows the dev to get at username/password. As of iOS 12 ASWebAuthenticationSession is the way to go.
does this package actually support SwiftUI??? I don't see anything about that
Hello Yes my question also. My app is being rejected at the review process because I was not using the embedded authentication session, but I am not able to make it work in my SwiftUI app.
Is there a way?
Hello I was finally able to get the ASWebAuthenticationSession to work in SwiftUI. I had to change the presentationAnchor function in the OAuth2ASWebAuthenticationPresentationContextProvider in file OAuth2Authorizer+iOS.swift to this:
public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
return ASPresentationAnchor()
}
This works for my specific use case, but I think a better implementation for this function to support all (or most) scenarios would be something like this:
public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
return context.view.window ?? ASPresentationAnchor()
}
Hope this helps, since the issue is tagged as "wont fix", but maybe the fix is not that hard at all (but it took for me many failed attempts. :D )
This should be fixed in 3.5.2 via #361 , can you check it works for you? You can set oauth2.authConfig.authorizeContext
to either a UIViewController on ASPresentationAnchor.
This should be fixed in 3.5.2 via #361 , can you check it works for you? You can set
oauth2.authConfig.authorizeContext
to either a UIViewController on ASPresentationAnchor.
Thanks I had version 5.3.1, so even if I set oauth2.authConfig.authorizeContext to ASPresentationAnchor, it would fail, because the presentationAnchor has a guard validating if the authorizeContext is a UIViewController, so it always failed. I had to clone the package and make the change to work with my project, so I then made some other changes specific to my project. I even implemented ASWebAuthenticationSession for macOS, which is not in 5.3.1 either, not sure if it is in the newest version.
So far I haven't been able to figure out how to use an embedded browser view for auth from a ContentView delegate. Does the API actually support this yet?