Search code examples
twitterlinq-to-twitter

Extract BearerToken from LinqToTwitter IAuthorizer


Hopefully a simple answer to what I think is a simple question.

Is it possible to Extract the BearerToken from the IAuthorizer once I am authenticated? After using LinqToTwitter to authorize, I want to make my own API calls and I need the BearerToken to do so.

Thank you for your time in advance!


Solution

  • I'm assuming you're talking about ApplicationOnlyAuthorizer. The demos assign to IAuthorizer, so you need to convert to ApplicationOnlyAuthorizer to expose the BearerToken, like this:

            await auth.AuthorizeAsync();
            string bearerToken = (auth as ApplicationOnlyAuthorizer).BearerToken;