本文整理汇总了C#中Session.Authenticate方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Authenticate方法的具体用法?C# Session.Authenticate怎么用?C# Session.Authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session.Authenticate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Authenticate
public bool Authenticate(string user, string password)
{
try
{
_session = new Session(API_KEY, API_SECRET);
string md5password = Utilities.MD5(password);
_session.Authenticate(user, md5password);
if (_session.Authenticated)
{
if (OnLogin != null)
OnLogin(this, EventArgs.Empty);
_lfmUser = new User(user, _session);
pollTimer.Change(0, Timeout.Infinite);
return true;
}
else
{
if (OnLoginFailed != null)
OnLoginFailed(this, EventArgs.Empty);
return false;
}
}
catch {
Debug.Print("Last.FM authentication error");
return false;
}
}
示例2: LastProfile
//private Session session;
//private Lastfm.Scrobbling.Connection connection;
//private Lastfm.Scrobbling.ScrobbleManager manager;
public LastProfile(string username, string password)
{
this.username = username;
this.password = password;
session = new Session("60d35bf7777d870ec958a21872bacb24", "099158e5216ad77239be5e0a2228cf04");
session.Authenticate(this.username, Lastfm.Utilities.md5(this.password));
connection = new Lastfm.Scrobbling.Connection("tst", "0.6", this.username, session);
manager = new Lastfm.Scrobbling.ScrobbleManager(connection);
}
示例3: LastfmService
/// <summary>
/// Constructs last.fm service object
/// assigning data from tag into local search
/// tokens. A last.fm authenticated session
/// is also setup based on user parameters and keys.
/// </summary>
/// <param name="tag">Song tag to search for</param>
public LastfmService(File release, int maxMaxResults=20)
{
Trace.WriteLine("Initializing LastFM Session");
Metadata metadata = release.Metadata;
// Initialize search tokens
Tokens = new Dictionary<string, string>();
Tokens.Add("artist", metadata.Artist);
Tokens.Add("release", metadata.Release);
Tokens.Add("title", metadata.Title);
MaxResults = maxMaxResults;
// Initialize lastfm session
session = new Session(key, secret);
session.Authenticate(username, Lastfm.Utilities.md5(passwd));
Trace.WriteLine("Session established with key: " + session.SessionKey);
}
示例4: GetSession
private static Session GetSession(Configuration configuration)
{
var username = configuration.Username;
var password = configuration.Password;
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
{
throw new AuthenticationException();
}
const string API_KEY = "fe136e7517c55e3d9f7aa295c2b02a72";
const string API_SECRET = "433cdcd4e96914dbcd71f176654e3bb3";
var session = new Session(API_KEY, API_SECRET);
session.Authenticate(username, password);
return session;
}