OSX OAuth redirect_uri in WebView

I am trying to authenticate an OSX application through OAuth, specifically using the Instagram API . I installed the application with Instagram - I have a client identifier and a secret, but I'm not sure how to handle redirect_url and how to get access_token, after authentication.

So far, I just have a simple WebView that loads the login page ...

 [[_webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://instagram.com/oauth/authorize/?client_id=THECLIENTID&redirect_uri=REDIRECT_URI&response_type=code"]]]; 
+6
source share
1 answer

Implement the - (void)webView:(WebView *)webView didFinishLoadForFrame:(WebFrame *)webFrame from the unofficial delegate of WebFrameLoadDelegate . Then (in Interface Builder) connect the output of frameLoadDelegate from the WebView to the instance of the class you embedded in - (void)webView:(WebView *)webView didFinishLoadForFrame:(WebFrame *)webFrame . Implementation Example:

 - (void)webView:(WebView *)webView didFinishLoadForFrame:(WebFrame *)webFrame { NSString *currentURL = [[[[webFrame dataSource] request] URL] absoluteString]; NSLog(@"Our WebView just loaded: %@", currentURL); if ([currentURL hasPrefix:yourRedirectURIString]) { // We are at the redirect URI! } } 
+4
source

All Articles