I'm trying to authenticate an OSX app via OAuth - specifically, using the Instagram API .
I've setup an app with Instagram - have the client ID and secret - but I'm unsure of how to deal with the redirect_url
and how to retrieve the access_token, once authenticated.
So far I've just a simple WebView which 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"]]];
Implement the method - (void)webView:(WebView *)webView didFinishLoadForFrame:(WebFrame *)webFrame
from the WebFrameLoadDelegate informal delegate. Then (in Interface Builder) wire up the outlet frameLoadDelegate
from the WebView to an instance of the class where you implemented - (void)webView:(WebView *)webView didFinishLoadForFrame:(WebFrame *)webFrame
. Example implementation:
- (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!
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With