Authentication Issue across Webpages

Aug 27, 2013 at 11:15 AM
Hi,

I am working in C#.Net, using SessionStateCredentials() and WebAuthorizer to use authentication across webpages.

I have authenticated the user successfully in the first page and want to access the same on the second page.

Can any body provide me a sample code to access credentials on second page to use in TwitterContext.

Is it something Like:
WebAuthorizer auth = new WebAuthorizer();
IOAuthCredentials credentials = new SessionStateCredentials();
var twitterCtx = new TwitterContext(auth1);

var followers = (from follower in twitterCtx.SocialGraph where follower.Type == SocialGraphType.Followers && follower.ScreenName == Convert.ToString(Session["ScreenName"]) select follower).SingleOrDefault();
In the above case, it is throwing error:
"Parameter name: You must provide a consumerKey."


Regards
AmitG
Aug 27, 2013 at 11:25 AM
Got it!

I have added ConsumerKey & ConsumerSecret to the Credentials and it works. Updated Code:
WebAuthorizer auth = new WebAuthorizer();
IOAuthCredentials credentials = new SessionStateCredentials();

if (credentials.ConsumerKey == null || credentials.ConsumerSecret == null)
{
                credentials.ConsumerKey = Preferences.ConsumerKey;
                credentials.ConsumerSecret = Preferences.ConsumerKeySecret;
 }
auth1.Credentials = credentials;
var twitterCtx = new TwitterContext(auth1);

var followers = (from follower in twitterCtx.SocialGraph where follower.Type == SocialGraphType.Followers && follower.ScreenName == Convert.ToString(Session["ScreenName"]) select follower).SingleOrDefault();
Thanks