objective-c – 我应该使用什么重定向uri(OAuth 2.0)?
发布时间:2020-12-16 07:33:11 所属栏目:百科 来源:网络整理
导读:我注册了谷歌API控制台的应用程序.我得到了我的客户端密码,客户端ID和两个重定向uris. //● urn:xxxxxxx:oob//● http://localhostxxxxxx 当然,我使用这些项目并成功请求令牌谷歌.但是当我点击授权按钮时(比如“你想授权这个应用程序吗?”是的), 两个响应发
我注册了谷歌API控制台的应用程序.我得到了我的客户端密码,客户端ID和两个重定向uris.
//● urn:xxxxxxx:oob //● http://localhostxxxxxx 当然,我使用这些项目并成功请求令牌谷歌.但是当我点击授权按钮时(比如“你想授权这个应用程序吗?”是的), 如果我使用urnxxxxxx,我会收到“操作无法完成.(com.google.HTTPStatus错误404.)”. //Or If I use http://localhostxxxxxxxxxxxxx and click Yes button,then nothing happens. 我该怎么办? (以下代码适用于谷歌阅读器.) #import "MasterViewController.h" #import "DetailViewController.h" #import "GTMOAuth2Authentication.h" #import "GTMOAuth2ViewControllerTouch.h" #import "GTMOAuth2WindowController.h" static NSString *const kKeychainItemName = @"Greader"; @interface MasterViewController () { NSMutableArray *_objects; } @end @implementation MasterViewController - (IBAction)authentication:signInToGoogle:(id)sender; {} - (GTMOAuth2Authentication * ) authForGoogle { NSString * url_string = @"http://www.google.com/reader/api/"; NSURL * tokenURL = [NSURL URLWithString:url_string]; NSString * redirectURI = @"xxxxoob"; GTMOAuth2Authentication * auth; auth = [GTMOAuth2Authentication authenticationWithServiceProvider:@"reader" tokenURL:tokenURL redirectURI:redirectURI clientID:@"xxxxx" clientSecret:@"xxxx"]; auth.scope = @"http://www.google.com/reader/api/"; return auth; } - (void)signInToGoogle { GTMOAuth2Authentication * auth = [self authForGoogle]; NSString* auth_string = @"https://accounts.google.com/o/oauth2/auth"; NSURL * authURL = [NSURL URLWithString:auth_string]; GTMOAuth2ViewControllerTouch * viewController; viewController = [[GTMOAuth2ViewControllerTouch alloc]initWithAuthentication:auth authorizationURL:authURL keychainItemName:kKeychainItemName delegate:self finishedSelector:@selector(viewController:finishedWithAuth:error:)]; [self.navigationController pushViewController:viewController animated:YES]; } 解决方法
你应该先了解oAuth.
通常,第一个链接是授权流程 – 您调用它并获取代码. 解释如何与oAuth合作完全超出了范围,但是您可以阅读和学习很多地方. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 关于连接PostgreSQL时提示 FATAL: password authentication
- c# – 如何在控制器和操作级别使用Authorize属性?
- flash – 如何修复此跨域ActionScript 3错误?
- c# – 在MVC中清除视图引擎会破坏站点地图的面包屑样式
- Oracle数据库安全策略分析(二)
- Cocos2d-x学习笔记(十五)-------->物理引擎
- 学界 | 将未来信息作为正则项,Twin Networks加强RNN对长期
- flex嵌入html完整页面and嵌入其他项目swf文件
- c# – DB ConnectionState = Open但context.SaveChanges抛出
- ActionScript3的3D引擎 - Papervision3D