I would like to submit a scrobble using a web services authentication
token (session_key), instead of a standard authentication token
(username + password). But looking at the Scrobbler class, I see that
the scrobble handshake is performed using:
token = md5(md5(password) + timestamp)
When I change the code to:
token = md5(shared_secret + timestamp)
(where shared_secret = network.session_key), I get a "Bad
authentication token" error. I know the token is valid because I can
'love' a track using the same network. Should this work, or am I doing
something wrong?
Best,
Owen.
Create a Network object using an api_key, api_secret and either the
session_key or the username and password_hash arguments. That should
authenticate the object, then use Network.get_scrobbler() to obtain a
Scrobbler object and use that instead.
-- Amr
> --
> You received this message because you are subscribed to the pylast mailing list.
> To post to this mailing list, send email to pyl...@googlegroups.com
> To unsubscribe from this group, send email to
> pylast+un...@googlegroups.com
> pylast is a python wrapper around last.fm's api. the project is hosted at http://code.google.com/p/pylast/ and the mailing list/group is at http://groups.google.com/group/pylast
import pylast, time
API_KEY = 'XXX'
API_SECRET = 'XXX'
n = pylast.get_lastfm_network(API_KEY, API_SECRET)
sg = pylast.SessionKeyGenerator(n)
url = sg.get_web_auth_url()
# open url in webbrowser and authenticate
sk = sg.get_web_auth_session_key(url)
nw = pylast.get_lastfm_network(API_KEY, API_SECRET, sk)
scrob = nw.get_scrobbler('tst', '1.0')
scrob.scrobble('Owen Meyers', 'I Like It', int(time.time()),
pylast.SCROBBLE_SOURCE_USER, pylast.SCROBBLE_MODE_PLAYED, 337)
>>> ScrobblingError: Invalid/Missing Parameter(s)
nw.username
>>> ''
nw.password_hash
>>> ''
Here we see that the network username and password are empty, which I
assume is the reason for the ScrobblingError: Invalid/Missing
Parameter(s). If I add the username, as such:
u = str(nw.get_authenticated_user())
nw = pylast.get_lastfm_network(API_KEY, API_SECRET, sk, u)
nw.username
>>> 'hiqlokey'
scrob = nw.get_scrobbler('tst', '1.0')
scrob.scrobble('Owen Meyers', 'I Like It', int(time.time()),
pylast.SCROBBLE_SOURCE_USER, pylast.SCROBBLE_MODE_PLAYED, 337)
>>> BadAuthenticationError: Bad authentication token
This time I get "BadAuthenticationError: Bad authentication token", I
am guessing because the Scrobbler._do_handshake() method is expecting
a password_hash (line 3563), which is empty because we authenticated
using the session_key. I know the token is valid because this works:
track = nw.get_track("Autechre", "Nine")
track.love()
And if i replace the password_hash with the valid session_key, I get
the same error, BadAuthenticationError: Bad authentication token.
Any ideas?
Owen.
On Feb 17, 12:14 pm, Amr Hassan <amr.has...@gmail.com> wrote:
> Hey Owen,
>
> Create a Network object using an api_key, api_secret and either the
> session_key or the username and password_hash arguments. That should
> authenticate the object, then use Network.get_scrobbler() to obtain a
> Scrobbler object and use that instead.
>
> -- Amr
>
-- Amr
On Feb 19, 7:34 am, Amr Hassan <amr.has...@gmail.com> wrote:
> Hey,
> Sorry for the delay, but I think I fixed it. Try the latest revision.
>
> -- Amr
>
> >> > pylast is a python wrapper around last.fm's api. the project is hosted athttp://code.google.com/p/pylast/andthe mailing list/group is athttp://groups.google.com/group/pylast