Persistent credentials

Feb 18, 2013 at 11:14 PM
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.
Coordinator
Feb 18, 2013 at 11:22 PM
Hi,

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. ;)

Joe
Feb 18, 2013 at 11:36 PM
Edited Feb 18, 2013 at 11:36 PM
400.
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)
Coordinator
Feb 19, 2013 at 6:02 AM
I just added a new demo, CredentialToStringAndLoadDemo.zip, 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.

@JoeMayo
Feb 19, 2013 at 1: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.