Tag: oauth 2.0

使用GTM OAuth2 for iOS检索用户电子邮件

我已经使用GTM OAuth 2库成功实现了身份validation。 但是现在我想拥有用户的电子邮件ID。 我应该如何继续。 我知道我必须在这里打个电话: – (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error { if (error != nil) { NSLog(@"SIGN IN ERROR : %@", error.description); // Authentication failed } else { // Authentication succeeded } }

oauth 2.0 webview ios sdk

我正在构build一个ios SDK并实现oauthstream。 基本上我需要做到以下几点: 用户点击一个button。 看到一个webviewpopup。 他们在webview中签名/注册,授予访问帐户的权限。 webview将它们redirect回url中的代码。 我需要以某种方式使用该代码进行api调用来获取他们的访问令牌。 我怎么能在objective-c上面做到这一点? 这意味着如何使用我的网站注册/签名stream向他们显示webview,并使用redirect的url中的代码访问访问令牌? 我知道如何做webview,但我不知道如何让代码来使用api调用。

如何从Swift 3获得MS翻译器访问令牌?

我正在尝试使用Swift 3的MS Translator API(目前在操场上玩,但目标平台是iOS)。 但是,当我试图获取OAuth2的访问令牌时,我陷入了困境。 我有以下代码(我试图移植来自示例的代码获取访问令牌 ): let clientId = "id".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! let clientSecret = "secret".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! let scope = "http://api.microsofttranslator.com".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! let translatorAccessURI = "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13" let requestDetails = "grant_type=client_credentials&client_id=\(clientId)&client_secret=\(clientSecret)&scope=\(scope)" let postData = requestDetails.data(using: .ascii)! let postLength = postData.count var request = URLRequest(url: URL(string: translatorAccessURI)!) request.httpMethod = "POST" request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") request.setValue("\(postLength)", forHTTPHeaderField: "Content-Length") request.httpBody […]

在应用程序中设置YouTube访问,坚持检索URL响应

我无法find任何答案或类似的问题,我的YouTube API难题,希望有人可以帮助。 我的iOS应用程序需要连接到用户的YouTube帐户,以便他们可以上传video给其他人看。 我遵循API文档,并设法连接到用户login到其帐户的validation部分(我使用的代码如下)。 它的工作原理是,它将用户带到Google的login页面,当login页面询问用户是否想授权应用程序访问帐户等。当用户接受,但我知道应该有数据返回给出应用程序authentication,令牌代码,所以它可以用来稍后在应用程序内上传video。 我的问题是….我如何检索这些数据? 当我点击接受它只是带我到另一个网页,但我不知道在哪里检索信息。 预先感谢任何能指引我正确方向的人。 #define kAuthUrl @"https://accounts.google.com/o/oauth2/auth?" #define kClientID @"client_id=xxxxxxxxxxxMyUniqueIDDetailsxxxxxxxxxx&" #define kRediretUri @"redirect_uri=urn:ietf:wg:oauth:2.0:oob&" #define kScopeUL @"scope=https://www.googleapis.com/auth/youtube.upload&" #define kResponse @"response_type=code" 上面的代码放在头文件中。 – (void)viewDidLoad { NSString *loginURL = [NSString stringWithFormat:@"%@%@%@%@%@", kAuthUrl, kClientID, kRediretUri, kScopeUL, kResponse]; NSURLRequest * urlReq = [NSURLRequest requestWithURL: [NSURL URLWithString:loginURL]]; [_webView loadRequest:urlReq]; [super viewDidLoad]; // Do any additional setup after […]

GTM OAuth不下载刷新令牌 – iOS

我正在使用Google的GTMOAuth for iOS / Mac SDK,以便能够连接诸如YouTube API和Instagram API之类的APIS。 这一切工作正常,但是当用户身份validation,我只能得到访问令牌。 这一切都很好,但过了一段时间访问令牌到期,用户不得不重新login这是可怕的。 我的问题是,当用户身份validation,我只能得到一个访问令牌,没有别的… 感谢您的帮助:)

Swift Alamofire从刷新令牌请求错误中获取令牌

我对使用Alamofire相当陌生,而且我正在用这个要求将我的头撞在墙上。 我正在使用GIDSignIn,并成功获取用户的令牌和刷新令牌,范围为[“ https://www.googleapis.com/auth/youtube.readonly ”]。 我试图完成这个请求,如网站上的示例所示。 该网站说,忽略使用iOS的client_secret ,我这样做。 POST /oauth2/v4/token HTTP/1.1 Host: www.googleapis.com Content-Type: application/x-www-form-urlencoded client_id=<your_client_id>& client_secret=<your_client_secret>& refresh_token=<refresh_token>& grant_type=refresh_token 以下是我如何用Alamofire实现它。 我的client_id是来自GoogleService-Info.Plist中CLIENT_ID键的值,这是一个以.apps.googleusercontent.com结尾的string。 refresh_token似乎也有我在网上看到的其他例子的正确格式。 let endpoint = "https://www.googleapis.com/oauth2/v4/token" let parameters = [ "client_id" : client_id, "refresh_token" : refresh_token, "grant_type" : "refresh_token" ] Alamofire.request(endpoint, method: .post, parameters: parameters, encoding: JSONEncoding.default) .responseJSON { (data) in print("data: \(data)") let json = […]

无法通过iPhone应用程序中的Oauth 2.0获取Google +的访问令牌

我正尝试在iPhone应用程序中使用Oauth 2.0访问Google+ API。 为此,我使用OauthConsumer库。 我得到了未经授权的request_token和授权码,但无法使用授权码将该request_token交换为access_token。 我得到错误为“invalid_request”。 下面是代码片段,我做了什么错误或缺less任何参数? 码: -(void)getAccessTokenWithAuthorizationCode:(NSString *)code { NSURL *accessTokenURL = [NSURL URLWithString:@"https://accounts.google.com/o/oauth2/token"]; OAMutableURLRequest *accessRequest = [[OAMutableURLRequest alloc] initWithURL:accessTokenURL consumer:consumer token:requestToken realm:nil // our service provider doesn't specify a realm signatureProvider:nil]; // use the default method, HMAC-SHA1 [accessRequest setHTTPMethod:@"POST"]; OARequestParameter *authCode = [[OARequestParameter alloc] initWithName:@"code" value:code]; OARequestParameter *redirectURI = [[OARequestParameter alloc] initWithName:@"redirect_uri" […]

Vimeo整合到ios oauth 2.0

我们已经用oauth 1.0集成了vimeo。 现在它不工作,必须使用oauth 2.0。 我find了https://github.com/nxtbgthng/OAuth2Client 。 但不明白如何使用它的Vimeo。 我们之前的代码是 OADataFetcher *fetcher; consumer = [[OAConsumer alloc]initWithKey:[dicVimeoInfo objectForKey:@"ConsumerKey"] secret:[dicVimeoInfo objectForKey:@"ConsumerSecret"]]; NSURL *vimeoURL=[NSURL URLWithString:kVimeoRestURL]; OAToken *token=[[OAToken alloc]initWithKey:[dicVimeoInfo objectForKey:@"AccessToken"] secret:[dicVimeoInfo objectForKey:@"AccessTokenSecret"]]; request = [[OAMutableURLRequest alloc] initWithURL:vimeoURL consumer:consumer token:token realm:nil signatureProvider:nil]; OARequestParameter* formatparameter = [OARequestParameter requestParameter:@"format" value:@"json"]; OARequestParameter* methodParameter = [OARequestParameter requestParameter:@"method" value:@"vimeo.channels.getAll"]; NSArray *params = [NSArray arrayWithObjects: formatparameter, methodParameter, nil]; […]

OAuth2login到SoundCloud最近返回错误域= NXOAuth2HTTPErrorDomain代码= 401“HTTP错误:401”

我正在尝试使用Objective-C SoundCloudAPI框架开发的iOS应用程序login到我的SoundCloud帐户https://github.com/sangtn/SoundCloudAPI 这工作像上次我使用它的魅力,但到今天,我收到以下错误信息: 错误域= NXOAuth2HTTPErrorDomain代码= 401“HTTP错误:401”UserInfo = {NSLocalizedDescription = HTTP错误:401} 使用相同的凭据(电子邮件和psw)授予我在Web平台和SoundCloud iOS应用程序上的访问权限。 我在SoundCloud平台上找不到任何最近的变化,他们的状态页面也没有显示任何故障,所以我问是否有人遇到这个问题,如果有人find了这个问题的原因?! 谢谢!

Djangoredirect到自定义URL

从我的Django应用程序,如何将用户redirect到somescheme://someurl.com? 为了给你一些上下文,以防万一它有帮助,我有一个用Python / Django编写的工作oauth2服务器,我需要允许用户注册具有自定义URLscheme的redirect_uris。 此自定义urlscheme用于处理本机应用程序内的redirect 。 我的第一反应是使用HttpResponseRedirect,但这个url有一个自定义的scheme,不是HTTP,所以我猜这不是我想要的。 预先感谢您提供的任何build议。 编辑:我没有尝试这个和Django正确返回响应redirect没有抛出一个错误,但浏览器不redirect到这个URL。 我正在使用Chrome来testing。 编辑2:HttpResponseRedirect在Safari浏览器中正常工作。