Class: Rockstar::Auth
Overview
Authentification
There are 2 ways to get an auth token :
Desktop-App
-
Get a new token to request authorisation:
token = Rockstar::Auth.new.token
-
Open a webbrowser with www.last.fm/api/auth/?api_key=xxxxxxxxxxx&token=xxxxxxxx
-
Wait for the User to confirm that he accepted your request.
-
Continue with “Get the session token”
Web-App
-
Redirect the user to www.last.fm/api/auth/?api_key=YOUR_API_KEY&cb=YOUR_RETURN_URL
-
If the user accepts, lastfm will redirect to YOUR_RETURN_URL?token=TOKEN
token = params[:token]
-
Continue with “Get the session token”
Get the session token
Instance Method Summary collapse
Methods inherited from Base
connection, fetch_and_parse, get_instance
Instance Method Details
#session(token) ⇒ Object
27 28 29 30 |
# File 'lib/rockstar/auth.rb', line 27 def session(token) doc = self.class.fetch_and_parse("auth.getSession", {:token => token}, true) Rockstar::Session.new_from_xml(doc) end |
#token ⇒ Object
32 33 34 35 36 |
# File 'lib/rockstar/auth.rb', line 32 def token doc = self.class.fetch_and_parse("auth.getToken", {}, true) token = (doc).at(:token).inner_html if (doc).at(:token) token end |