Skip to content

RequestCredentialsParameters.FromCallbackUrlAsync error when no oauth_verifier returned  #1081

@redoc209

Description

@redoc209

When authenticating a Twitter app, if the user selects "Cancel" instead of "Authorize App" a "denied" parameter is sent back and no "oauth_token" which causes an error in RequestCredentialsParameters.FromCallBackURLAsync.

ERROR: "System.ArgumentException: oauth_verifier query parameter not found, this is required to authenticate the user
Parameter name: callbackUrl"

 public async Task<ActionResult> TwitterUserAuthCallbackAsync()
        {
    
            var appClient = new TwitterClient(TWITTER_API_KEY, TWITTER_API_SECRET);

            string q = Request.QueryString.ToString();
            // Extract the information from the redirection url
            var requestParameters = await RequestCredentialsParameters.FromCallbackUrlAsync(q, _myAuthRequestStore);

            // Request Twitter to generate the credentials.
            var userCreds = await appClient.Auth.RequestCredentialsAsync(requestParameters);

            var userClient = new TwitterClient(userCreds);
            var user = await userClient.Users.GetAuthenticatedUserAsync();

        }

Steps to recreate:
Send request to connect to Twitter.
Instead of Authorize App button, click Cancel button and Twitter sends user to another page with "return to MyApp" button.
The button has a Twitter generated return URL that looks like this.
https://mydomain.com/TwitterUserAuthCallbackAsync?tweetinvi_auth_request_id=XXXXXXXXXXdenied=XXXXXX

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions