Nullstr1ng / spotify-local-api

Automatically exported from code.google.com/p/spotify-local-api
0 stars 0 forks source link

SpotifyAPI.GetOAuth() request returns empty string / tokenData (After a couple of days of fun) #9

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by jtmbussc...@gmail.com on 19 Feb 2014 at 3:26

GoogleCodeExporter commented 9 years ago
Seems Spotify changed something in their protocol. We need to wait untill 
author of the project fix that :/

Original comment by super2pl...@gmail.com on 21 Feb 2014 at 8:13

GoogleCodeExporter commented 9 years ago
Actually, you only need to change the track URI and add an User-Agent
Use this function for the GetOAuth()
To translate it into C# use 
http://www.developerfusion.com/tools/convert/vb-to-csharp/

VB.NET:
    Public Function GetOAuth() As String
        Dim client As New WebClient
        client.Headers.Add("User-Agent: SpotifyAPI")

        Dim raw As String = client.DownloadString("https://embed.spotify.com/openplay/?uri=spotify:track:6uQ192yNyZ4W8yoaL0Sb9p")
        raw = raw.Replace(" ", "")
        Dim lines As String() = raw.Split(New String() {vbLf}, StringSplitOptions.None)
        For Each line As String In lines
            If line.StartsWith("tokenData") Then
                Dim l As String() = line.Split(New String() {"'"}, StringSplitOptions.None)
                Return l(1)
            End If
        Next

        Throw New Exception("Could not find OAuth token")
    End Function

Original comment by stefy1...@gmail.com on 21 Feb 2014 at 8:29

GoogleCodeExporter commented 9 years ago
Thank you very much for you're quick reply. It was succesfull !
Great ! Thanks.

Original comment by jtmbussc...@gmail.com on 21 Feb 2014 at 8:44

GoogleCodeExporter commented 9 years ago
Here is the new dll with the changes

Original comment by simon.f....@gmail.com on 11 Apr 2014 at 6:11

Attachments:

GoogleCodeExporter commented 9 years ago
I would suggest to use https://open.spotify.com/token instead of this 
embed.spotify.com hack.

Original comment by val...@gmail.com on 16 Apr 2014 at 4:32