Reputation: 2997
OAuth2 on iOS app load an uiwebview to let the user accept the connection(after login with his google account). I want to load a uiwebview to prompt the user to accept the connection... I must intercept when the user allow the app and than close the webview and get the code returned as parameter in the redirect url.
How can I do? Thanks
Upvotes: 0
Views: 3202
Reputation: 752
I have written a library to do this (used it in a couple of my own apps). You can find it in github: LHOAuth2LoginViewController
However, I think my library won't work directly with Google API, since I recall that they don't support response_type=token
, but instead you have to use response_type=code
. And also there were some other differences to the OAuth2 rfc6749.
But at least you should get the idea for how to intercept the redirection and close the webview. You can check the redirection url in the -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
UIWebViewDelegate method and call dismissViewControllerAnimated:YES completion:^() {}
Upvotes: 2