I am using Linq2Twitter in web forms and it works great except that I really want to keep the Asp.Net Login framework in place since it handles the local membership issues nicely for me.
In the VS 2012 template it uses the OpenAuth object and in RegisterExternalLogin there is this:
// Verify the OpenAuth payload
var authResult = OpenAuth.VerifyAuthentication(redirectUrl);
authResult includes a returned AccessToken which I thought was all I would need to make subsequent call on behalf of a user, like this, to subscribe the current logged in user to a List:
(where 'data' contains the previously saved authResult.ExtraData["accesstoken"] string)
UsersOpenAuthData data = (from d in sm.DataContext.UsersOpenAuthDatas
where d.MembershipUserName == User.Identity.Name
SessionStateCredentials cred = new SessionStateCredentials
ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"],
ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"],
AccessToken = data.AccessToken
WebAuthorizer wa = new WebAuthorizer
Credentials = cred,
PerformRedirect = authUrl => Response.Redirect(authUrl)
TwitterContext twitterCtx = new TwitterContext(wa);
List list = twitterCtx.AddMemberToList(null, MyAccountName, MyListID, null, null, null);
and here I get a 401, I suspect because Credentials wants an OAuthToken value separately from the AccessToken value ?
I know that my App is OK and my config Consumer values are correct as I am able to use them to log in / register elsewhere.
Can this be made to work or do I need to have L2T all the way through in order to get both tokens?