When I do a request to authenticate a user , the user’s TokenSecret property is not readable. I can view (AccessToken and TokenSecret) it when I step through my code in .Net QuickView, and when I copy and paste it manually with an email request in my app it works. But I do not know how to retrieve the tokenSecret value when I run the code. [response.TokenSecret] is not readable.
protected override AuthenticationResult VerifyAuthenticationCore(AuthorizedTokenResponse response)
{
accessToken = response.AccessToken;
string userId = response.ExtraData["user_id"];
string userName = response.ExtraData["screen_name"];
var profileRequestUrl = new Uri("https://api.twitter.com/1/users/show.xml?user_id="
+ EscapeUriDataStringRfc3986(userId));
var profileEndpoint = new MessageReceivingEndpoint(profileRequestUrl, HttpDeliveryMethods.GetRequest);
HttpWebRequest request = this.WebWorker.PrepareAuthorizedRequest(profileEndpoint, accessToken);
var extraData = new Dictionary<string, string>();
extraData.Add("accesstoken", accessToken);
// Here we do need WebConsumer
//InMemoryTokenManager inMemoryTokenManager = new InMemoryTokenManager(this._appKey, this._appSecret);
try
{
// inMemoryTokenManager.StoreNewRequestToken(request, response);
using (WebResponse profileResponse = request.GetResponse())
{
using (Stream responseStream = profileResponse.GetResponseStream())
{
XDocument document = LoadXDocumentFromStream(responseStream);
foreach (var node in document.Descendants("user").Nodes<XElement>())
{
if (node.NodeType == XmlNodeType.Element)
{
extraData.AddDataIfNotEmpty(document, ((System.Xml.Linq.XElement)(node)).Name.LocalName);
}
}
}
}
}
catch (Exception)
{
// inMemoryTokenManager.StoreNewRequestToken(request, response);
// At this point, the authentication is already successful.
// Here we are just trying to get additional data if we can.
// If it fails, no problem.
}
UserClass userclass =new UserClass
{
Token = response.AccessToken,
UserID = userId,
ScreenName = userName,
Secret = "DmdDQmmEWJffl0HclZ6E8U3VWZfQanMYlTuAHbmYVYVmY"//response.TokenSecret,
};
return new AuthenticationResult(
isSuccessful: true, provider: this.ProviderName, providerUserId: userId, userName: userName, extraData: extraData);
}