Authorize always asks for rights permissions

Nov 27, 2013 at 2:12 AM
Love LinkToTwitter. Have been using it for a while for Twitter related API calls, and have the auth flow working fine for that scenario.

What I would like to do is create a simple "log in with twitter' button. We already have all their credentials.

I have it working, however every time the user is asked to re-authorize the application. I'd simply like Twitter to authenticate the user and pass back their Twitter credentials (assuming the user has already authorized the app).

I'm sure I'm missing something really basic, but how?
IOAuthCredentials credentials = new SessionStateCredentials();

                if (credentials.ConsumerKey == null || credentials.ConsumerSecret == null)
                {
                    credentials.ConsumerKey = this.twitterConsumerKey;
                    credentials.ConsumerSecret = this.twitterConsumerSecret;
                }
                
                var auth = new MvcAuthorizer
                {
                    Credentials = credentials,
                };

                if (string.IsNullOrWhiteSpace(credentials.ConsumerKey) ||
                    string.IsNullOrWhiteSpace(credentials.ConsumerSecret))
                {
                    return RedirectToAction("Error");
                }

                auth.CompleteAuthorization(Request.Url);

               //check for our user details using auth.UserId and log them in
Coordinator
Nov 27, 2013 at 3:04 AM
Hi,

You could try the SignInAuthorizer. There's a demo in the downloadable source code, in the WebFormsDemo project.

@JoeMayo on Twitter
Nov 27, 2013 at 6:34 PM
Thanks Joe,

The SignInAuthorizer didn't work for me (kept getting a null reference exception), however upon looking at the source it seemed that the equivalent would just be to use the regular MvcAuthorizer and set:

auth.OAuthAuthorizeUrl = "https://api.twitter.com/oauth/authenticate";

That worked a treat.

Cheers,

Chris
Coordinator
Nov 27, 2013 at 6:36 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Nov 27, 2013 at 6:40 PM
Chris,

Thanks for the follow-up. Looks like I can use that to build an MvcSignInAuthorizer.

Joe