This project has moved and is read-only. For the latest updates, please go here.

Persistent credentials

Feb 19, 2013 at 12:14 AM
I'm having a hard time saving the authorization credentials in the simple console example.
After my PinAuthorizer was authorized through normal means (Opening the website, entering the pin, etc.), the AccountSample worked just fine. However, when calling auth.Credentials.Load("XXX"), filled with the content of auth.Credentials.ToString(), I get an Error 400.

Would it be possible for someone to explain to me why this is happening? I am already trying to implement simple Credentials serialization for more than 7 hours and have developed a serious desire to smash my computer with a sledgehammer.
Feb 19, 2013 at 12:22 AM

Are you getting a 400 or a 401. I've written a 401 FAQ because these problems are so prevalent when trying to get started with Twitter OAuth authentication.

On the Load method, make sure you have all 4 credentials (ConsumerKey, ConsumerSecret, OAuthToken, and AccessToken). You can also set the credential properties manually. Remember that you can pull out all 4 credentials after a successful authorization and save them.

Hope this helps save a poor defenseless computer. ;)

Feb 19, 2013 at 12:36 AM
Edited Feb 19, 2013 at 12:36 AM
I have already tried to do so. After successfully authenticating I wrote the content of auth.Credentials.ToString() to a file. However, when using auth.Credentials.Load() with the content of the file, all API calls fail with error 400.

Can you maybe modify the Account example to write the credentials to a file and read them before trying to authenticate online?
That should only be a few lines (Stuff like if(File.Exists) and such...) but would really help me out

(After 4 years of experience with C#, this is really embarassing)
Feb 19, 2013 at 7:02 AM
I just added a new demo,, to the Samples page. In particular, look at the PerformAuthorization method. It calls a method named GetCredentials to read from the file if available, otherwise it loads the normal ConsumerKey and ConsumerSecret. At the end of PerformAuthorization, you'll see where it writes the credentials out to the file.

Feb 19, 2013 at 2:18 PM
I've looked at your example and it works. I still can't figure out why it didn't work when I tried it.

Anyways, thank you.