This project has moved. For the latest updates, please go here.

Getting Twitter Access token and secret.

Oct 1, 2013 at 9:39 AM
Hi,

I've been trying to get the twitter access token and secret so i can post tweets on people's behalf.
The problem is that it doesn't seem its possible at the moment. In the
OnAuthenticated = (context) =>
i try to read the response body but that just gives an exception. I've also looked at the Katana code, and all it does is get the access token, and then ignores and doesn't add it to the user claims or to the context. it only passes along the userID and name as claims. I can of course easily change the katana code so it works for me, but i would rather work with the original version if that's possible. So what I am wondering if this is a bug, or am i doing something wrong. hope someone can help.
Coordinator
Oct 1, 2013 at 8:59 PM

In the twitter OnAuthenticated call try using the context.AccessToken and AccessTokenSecret properties…

Although it looks like adding additional scopes to post on people’s behalf will be a problem.

Oct 2, 2013 at 8:32 AM
the twitter Authentication context doesn't have an accessToken or AccessTokenSecret, that is the issue. it only has a userId and a screenName. the accessToken and AccessTokenSecret isn't set. I think perhaps this could be that it was forgotten to add it:
public class TwitterAuthenticatedContext : BaseContext
{
    public TwitterAuthenticatedContext(
        IOwinContext context, 
        string userId, 
        string screenName)
        : base(context)
    {
        UserId = userId;
        ScreenName = screenName;
    }

    public string UserId { get; private set; }
    public string ScreenName { get; private set; }

    public ClaimsIdentity Identity { get; set; }
    public AuthenticationProperties Properties { get; set; }
}
}

(see no access token or secret)

adding additional scopes isn't a problem i have already managed this. the only issue is that i can't get to the access token and secret. And i actually don't think its possible to get it unless it gets add to either the identity claims or to the context.
Coordinator
Oct 2, 2013 at 5:51 PM
AccessToken and AccessTokenSecret were added to the TwitterAuthenticatedContext after RC1. You can verify by looking at the dev or release branches.

Instructions for installing the nighly dev or release packages are here: https://katanaproject.codeplex.com/.