当前位置: 首页 > 知识库问答 >
问题:

Spotify登录错误-canOpenURL

孙才捷
2023-03-14

我试图了解Spotify的登录/授权流程。我遵循一个教程,最终得到了这段代码。当我尝试登录时,会出现以下错误:-canOpenURL:URL失败:“spotify操作:/”-错误:“(null)”

我查看了回购协议,发现我需要将spotify action和spotify添加到信息中。在LSApplicationQueriesSchemes下注册。然而,在这样做后,我仍然得到上述错误。

class SpotifyLoginViewController: UIViewController, SPTAuthViewDelegate{
let kclientID = " my client id"
let kcallbackURL = "my callback"

@IBAction func loginSpotify(sender: AnyObject){
    SPTAuth.defaultInstance().clientID = kclientID
    SPTAuth.defaultInstance().redirectURL = NSURL(string: kcallbackURL)
    SPTAuth.defaultInstance().requestedScopes = [SPTAuthStreamingScope]
    SPTAuth.defaultInstance().sessionUserDefaultsKey = "SpotifySession"
    //SPTAuth.defaultInstance().tokenSwapURL = NSURL(string: ktokenSwapURL) //you will not need this initially, unless you want to refresh tokens
   // SPTAuth.defaultInstance().tokenRefreshURL = NSURL(string: ktokenRefreshServiceURL)//you will not need this unless you want to refresh tokens

    let spotifyAuthViewController = SPTAuthViewController.authenticationViewController()
    spotifyAuthViewController.delegate = self
    spotifyAuthViewController.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
    spotifyAuthViewController.definesPresentationContext = true
    presentViewController(spotifyAuthViewController, animated: false, completion: nil)

}


func authenticationViewController(authenticationViewController: SPTAuthViewController!, didLoginWithSession session: SPTSession!) {
    print("Logged In")
}

func authenticationViewController(authenticationViewController: SPTAuthViewController!, didFailToLogin error: NSError!) {
    print("Failed to Log In")
    print(error)
    authenticationViewController.clearCookies(nil)
}

func authenticationViewControllerDidCancelLogin(authenticationViewController: SPTAuthViewController!) {
    print("User Canceled Log In")
    authenticationViewController.clearCookies(nil)
}
}

共有2个答案

仲孙经赋
2023-03-14

如果Spotify应用程序没有安装在您的设备上。所以您不能用网址“Spotify-action://”打开Spotify原始应用程序。您可以用网络浏览器登录。它将打开spotify.com,验证后,它将重定向到重定向网址(应用链接)。

您只需要更改一个参数。setsionManager.initiate会话(具有:范围,选项:。客户端,呈现:自我)该参数是选项。请将其更改为。默认。因此它将打开safari浏览器登录Spotify帐户。我希望这将是帮助。

秦彦君
2023-03-14

如果您的设备上未安装Spotify应用程序,则打开Spotify的操作将失败,控制台将打印错误:-canOpenURL:URL失败:“Spotify操作:/”-错误:“(null)”。这适用于未安装在设备上的任何应用程序,并且会尝试启动不存在的应用程序。

 类似资料:
  • 我正在制作一个包含Spotify集成的应用程序,我被跟踪了这个链接https://developer.spotify.com/technologies/spotify-android-sdk/tutorial/ 通过引用此链接,我被置于“festevo://callback“作为回调重定向URI 当我试图登录Spotify时,每次我都遇到同样的错误。 请告诉我为什么会这样。。。 非常感谢。

  • 我试图添加Spotify登录功能到我的web应用程序与帐户-Spotify包。 这里是我的包裹: 我在spotify的api门户网站上创建了一个应用程序,并在帐户spotify设置登录按钮中输入了客户机密和客户id。

  • 编辑:我发现了一个类似的问题,专门针对Facebook的登录。我正在使用电子邮件认证,但问题/解决方案可能是相同的。 userinfo={nsunderlyingerror=0x14704d4b0{Error domain=firauthinternalerrordomain code=3“(null)”userinfo={firautherroruserinfoderializedrespons

  • 我已经从github下载了spotify演示。com测试版-第3版。登录后,它会重定向到spotify的safari登录页面,但不会返回应用程序。在第二次运行应用程序并登录时,它将打开帐户。spotify。com并给出错误无效的_客户端:无效的重定向URL

  • 我已经创建了一个登录名。html页面和登录名。php脚本。在脚本中,它将首先获得我们输入的用户名和密码,然后使用数据库检查用户名或密码是否存在,如果用户有效,则它将检查他的部门id,并使用部门权限打开他们的页面,但问题是无论他们的部门是什么,都会一直打开管理页面。请帮我做这件事。 这是我的login.html代码 登录。php脚本

  • 我使用cakephp2.1和我在UsersController中使用登录操作如下。 和登录名。ctp代码如下。 当使用电子邮件和密码提交表单时,用户无法登录,因此显示错误“无效电子邮件或密码,请重试”。就连我都把这美元给递了-