【问题标题】:Signature_invalid error from oAuth while querying for Google Request Token in IOS在 IOS 中查询 Google 请求令牌时来自 oAuth 的 Signature_invalid 错误
【发布时间】:2023-04-05 05:40:01
【问题描述】:

我正在使用 oAuth 为谷歌的“纬度”范围获取未注册安装应用程序的请求令牌,我得到的响应字符串为

签名无效 base_string:GET&HTTPS%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Danonymous%26oauth_nonce%3D1D759072-DB2B-4E21-AA23-67CADF98C14A%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1306734462%26oauth_version%3D1.0%26scope% 3Dhttps%253A%252F%252Fwww.googleapis.com%252Fauth%252Flatitude%26xoauth_displayname%3DTaj%2520Vivanta

我用来获取请求令牌的代码如下

OAConsumer *consumer = [[OAConsumer alloc] initWithKey:@"anonymous" secret:@"anonymous"]; OAMutableURLRequest *request = [[[OAMutableURLRequest alloc] initWithURL:url consumer: consumer token:token realm:nil signatureProvider: nil] autorelease]; 如果(!请求)返回; [请求 setOAuthParameterName:@"scope" withValue:[@"https://www.googleapis.com/auth/latitude" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; [请求 setOAuthParameterName:@"xoauth_displayname" withValue:@"Taj Vivanta"]; [请求 setHTTPMethod:@"GET"]; OADataFetcher *fetcher = [[[OADataFetcher alloc] init] autorelease]; [fetcher fetchDataWithRequest:请求委托:self didFinishSelector:成功 didFailSelector:失败];

请帮我解决这个问题,谢谢

【问题讨论】:

    标签: ios oauth


    【解决方案1】:

    正如 google Document 明确建议的那样,范围和 xoauth_displayname 参数应该在 URL 中,但在上面的代码中,我将这些参数放在请求标头中。

    【讨论】:

      猜你喜欢
      • 2011-09-18
      • 2013-07-21
      • 1970-01-01
      • 2012-07-26
      • 1970-01-01
      • 2018-10-28
      • 1970-01-01
      • 1970-01-01
      • 2012-11-06
      相关资源
      最近更新 更多