WebView中的OSX OAuth redirect_uri [英] OSX OAuth redirect_uri in WebView

查看:96
本文介绍了WebView中的OSX OAuth redirect_uri的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过OAuth对OSX应用进行身份验证-特别是使用 Instagram API . 我已经使用Instagram设置了一个应用程序-具有客户端ID和密码-但是我不确定如何处理redirect_url以及一旦身份验证后如何获取access_token.

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.

到目前为止,我只有一个简单的WebView可以加载登录页面...

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!
    }
}

这篇关于WebView中的OSX OAuth redirect_uri的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆