Exemplo n.º 1
0
        /// <summary>
        /// Gets an authorised Session Key for the API Key and Secret provided. You must Authorise first, see <see cref="GetAuthorisationUri"/>.
        /// See http://www.last.fm/api/desktopauth for the full Authorisation process. Sets the Authentication Session for this instance at the same time
        /// </summary>
        /// <returns>The session key returned from Last.fm as string to be cached or stored by the client</returns>
        /// <remarks>Session Keys are forever. Once a client has obtained a session key it should be cached or stored by the client, and the next time this
        /// Scrobbler is instantiated, it should be passed in with the constructor arguments</remarks>
        /// <exception cref="InvalidOperationException"/>
        public Session GetSession()
        {
            //if (Authentication.Session != null && !string.IsNullOrEmpty(Authentication.Session.Key))
            //    throw new InvalidOperationException("This Scrobbler already has a Session Key");

            // Get a token
            GetAuthenticationToken();

            // Request a Session
            AuthApi.GetSession(Authentication, AuthenticationToken);

            if (Authentication.Session == null)
            {
                throw new InvalidOperationException();
            }

            return(Authentication.Session);
        }