使用 Soundcloud API OAuth2 时出现 401 错误代码
我正在使用 Soundcloud 附带的 TestApp 应用程序创建一个 iPhone 应用程序 Coca API 包装器下载。
当我使用密钥和客户端 ID 以及回调 URL 时,没有 问题。我可以使用我的 Soundcloud 帐户登录该应用程序并上传 只需按一下按钮即可查看我的轨迹。
当我将客户端 ID、密钥和回调 URL 切换到我想要的那个时 已在我的开发者帐户上列出行为更改。我可以登录 该应用程序已注册到我的帐户,但在我的用户名之前 发布到应用程序时,我在代码中的此级别收到401:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
{
#if (NXOAuth2ConnectionDebug)
NSLog(@"%.0fms (SUCC) - %@", -[startDate
timeIntervalSinceNow]*1000.0, [self descriptionForRequest:request]);
#endif
printf("connectionDidFinishLoading\n");
if (sendConnectionDidEndNotification) [[NSNotificationCenter
defaultCenter] postNotificationName:NXOAuth2DidEndConnection
object:self];
sendConnectionDidEndNotification = NO;
printf("connectDidFinishLoading.1\n");
printf("self.statusCode: %d \n", self.statusCode);
因为我的应用程序与密钥、id 和回调 URL 配合得很好 在 TestApp 中给出,我很奇怪当我切换这些时 我得到 401 值。
只是为了进一步澄清:
这是一个 iOS 应用程序,我肯定已经放置了正确的密钥和 ID 在正确的位置。来自 souncloud.com 的客户端 ID 和 Secret(不是 sandbox-soundcloud)直接插入到
#ifdef kUseProduction
下的值中,这在我看来是正确的做法。另外,在我的 info.plist 文件中 我有 URL 标识符
com.imc
URL 方案
http://imc
和与 Soundcloud 提交的重定向 URI 完全匹配的
。同样,我已将 kCallbackURL 定义为
http://imc
还有其他想法吗?
I am creating an iPhone app using the TestApp application that came with the Soundcloud
Coca API wrapper download.
When I use the key and client id and call back URL there is no
problem. I can log into the app using my Soundcloud account and upload
the my tracks at the touch of a button.
When I switch the client id, key and callback URL to the one that I
have listed on my developer account the behavior changes. I can log in
and the app gets registered to my account, but before my username is
posted to the app I get a 401 at this level in the code:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
{
#if (NXOAuth2ConnectionDebug)
NSLog(@"%.0fms (SUCC) - %@", -[startDate
timeIntervalSinceNow]*1000.0, [self descriptionForRequest:request]);
#endif
printf("connectionDidFinishLoading\n");
if (sendConnectionDidEndNotification) [[NSNotificationCenter
defaultCenter] postNotificationName:NXOAuth2DidEndConnection
object:self];
sendConnectionDidEndNotification = NO;
printf("connectDidFinishLoading.1\n");
printf("self.statusCode: %d \n", self.statusCode);
Since my app works perfectly fine with the key, id and callback URL
given in the TestApp it is strange to me that when I switch these
values I get the 401.
Just to clarify further:
It is an iOS app and I have definitely placed the correct key and id
in the correct spot. The client ID and Secret from souncloud.com (not
sandbox-soundcloud) are plugged into the values directly under
#ifdef kUseProduction
This seems to me the correct thing to do. Also, in my info.plist file
I have the URL identifier
com.imc
and the URL scheme
http://imc
which matches exactly the redirect URI have filed with Soundcloud.
Likewise I have defined my kCallbackURL as
http://imc
Any other thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于从 SoundCloud 可爱的人们那里得到了答案。
I finally got the answer from the lovely people at SoundCloud.