call back from safari (oauth)

本文介绍如何在 iPhone 上使用自定义 URI 方案进行 OAuth 认证,避免让用户手动输入 PIN 码验证。通过将应用绑定到特定 URI 方案,并将其设置为 oauth_callback 参数的一部分,可以实现从 OAuth 服务提供商到应用的无缝回调。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

is it possible to authenticate with oauth, on the iphone, without making the user enter a pin?


http://stackoverflow.com/questions/2160138/is-it-possible-to-authenticate-with-oauth-on-the-iphone-without-making-the-use

Yup. What you can do is register a custom URI scheme with your application and use it in the oauth_callback parameter. This saves you from having to use out-of-band callback configuration, which requires the user to manually enter a verifier, as you describe.

Details on registering a custom URI scheme for your app here:

http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html

Edited - Elaborating

Using a custom URI scheme, you can instruct an OAuth Service Provider to 'call back' to your iPhone application when a user authorizes a Request Token. This is an alternative to the cumbersome "out-of-band callback" workflow that requires a user to authorize a Request Token, and then be given a verifier code that they manually enter via your application. It is also more analogous to how Web Applications that use OAuth behave.

The steps involved in using a URI scheme would be the following:

  1. Using the above link as a guide, bind a custom URI scheme to your iPhone application (i.e. "myapp://").
  2. When requesting a Request Token from the OAuth Service Provider, provide a URI that uses your custom scheme as the value of the 'oauth_callback' parameter. For example, oauth_callback=myapp://oauth/callback
  3. When you get a Request Token, direct the user to the Service Providers authorization endpoint URL via the browser (launch Safari, send the user to http://example.com/oauth/authorize?oauth_token=token).
  4. If the user chooses to authorize the Request Token, the Service Provider will redirect them (usually via a 301 HTTP Status header) to the URI you provided in step # 2.
  5. Safari will recognize that the URI uses a scheme that is bound to your application and launch your app.
  6. When the callback is called (again, see the above linked guide for details) you will be able to exchange the authorized OAuth Request Token for an Access Token.
  7. Finally, with an Access Token you will be able to access Protected Resources from the OAuth Service Provider.

Does that make more sense?

Just in macosx now.
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *helperAppPath = [[mainBundle bundlePath]
  stringByAppendingString:@"/Contents/Resources/Helper.app"];


[[NSWorkspace sharedWorkspace] launchApplication:helperAppPath];
投机的方法:(调用homesearch)
<meta http-equiv="Refresh" content="0;URL=homessearch://jp.co.homes.iphomes">
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值