Skip to content

AuthFlow.InitAuthentication Only Giving oauth_token #1031

Open
@DeliverPhilip

Description

@DeliverPhilip

I am working on Authentication code for Twitter using Teetinvi, but the authentication code shown in the documentation only ever gives back an oauth_token in the API response. I am using this code:

public string TwitterAuth()
        {
            var appCreds = new ConsumerCredentials(ConsumerKey, ConsumerSecretKey);

            // Specify the url you want the user to be redirected to
            var redirectURL = "http://" + HttpContext.Current.Request.Url.Authority + "/Clients/ValidateTwitter";
            if (redirectURL.Contains("localhost"))
                redirectURL = "http://" + "127.0.0.1" + "/Clients/ValidateTwitter";
            authenticationContext = AuthFlow.InitAuthentication(appCreds, redirectURL);

            return authenticationContext.AuthorizationURL;
        }

Where ValidateTwitter is an approved redirect in the Twitter App settings. ValidateTwitter runs this code:

public ActionResult ValidateTwitter()
        {
            var twitterHelper = new DeliverMedia.Web.Framework.TwitterHelper();
            var twitterWrapper = new DeliverMedia.TwitterServices.TwitterApiWrapper(twitterHelper.Consumer, twitterHelper.ConsumerSecret);
            twitterWrapper.ValidateTwitterAuth();

            return View();
        }`

And ValidateTwitterAuth is:

`public (string accessToken, string secretAccessToken) ValidateTwitterAuth()
        {
            // Get some information back from the URL
            var verifierCode = HttpContext.Current.Request.Params.Get("oauth_verifier");

            // Create the user credentials
            var userCreds = AuthFlow.CreateCredentialsFromVerifierCode(verifierCode, authenticationContext);

            // Do whatever you want with the user now!
            var creds = Tweetinvi.User.GetAuthenticatedUser(userCreds);
            return (creds.Credentials.AccessToken, creds.Credentials.AccessTokenSecret);
        }

I split ValidateTwitter and ValidateTwitterAuth because the project that has the TweetInvi code is separate from the project that has my webviews. The TweetInvi code is then called through helpers and wrappers in the webview project.

But authenticationContext in TwitterAuth() always only has an oauth_token parameter, while the documentation says it should have oauth_token, oauth_verifier and authorization_id.

I am using the newest version of TweetInvi

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions