Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Skynari · Jan 25, 2011 at 09:46 AM · wwwwwwformtwitter

POST data via WWWForm is not working for Twitter OAuth process.

First, I'm not very familiar with web programming but will try my best to explain the issue.

Basically, I'm trying to get "request-token" from Twitter by following this doc: http://dev.twitter.com/pages/auth#request-token

Here is how I build WWWForm and pass it to WWW.

WWWForm form = new WWWForm(); form.AddField("Host", "api.twitter.com", Encoding.ASCII); form.AddField("Authorization", "OAuth realm=\"Twitter API\",oauth_consumer_key=\"lmlQeOdr4ScvXYOPg3roGg\",oauth_nonce=\"1E240\",oauth_signature_method=\"HMAC-SHA1\",oauth_timestamp=\"1295947023\",oauth_version=\"1.0\",oauth_signature=\"mduLroP0fYadFiQljW6P6ueort0%3D\"", Encoding.ASCII);

WWW web = new WWW("https://api.twitter.com/oauth/request_token?oauth_callback=oob", form);

while (!web.isDone) { Debug.Log("Wait..."); } Debug.Log(web.text);

And I always get "Failed to validate oauth signature and token".

I thought it was probably because my authorization header was incorrect.

However, I've found that if I use Fiddler(http://www.fiddler2.com) and build a request with the exact same header, it goes through and Twitter responses with "request_token" instead of the error message.

Can anyone help me to find what I'm doing wrong here? Thanks!

p.s. Please do not just copy the code and run it. It wouldn't work as the authorization header has time-stamp and it's only valid for a certain period of time.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Bunny83 · Jan 25, 2011 at 10:49 AM

I don't use Twitter but i think you mixed post data with HTTP headers. Host and Authorization are HTTP header fields and should be included in the header and not in the request body as post data. WWWForm represents a html < form > and with AddField() you just add post data to the form. You need to setup your header. WWWForm.headers is what you need just check the script reference.

Look at WWWForm.headers(Unity) and maybe List of HTTP header fields(wikipedia)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Jan 25, 2011 at 10:56 AM 0
Share

Just another hint if you build for webplayer: "Note: The security sandbox present in web-player builds prevents you from accessing content not hosted the server where the webplayer is hosted."

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Error when creating http request. GET request with custom headers is not supported. 3 Answers

get twitter access token 1 Answer

"SecurityException: No valid crossdomain" even though the webplayer didn't even try to get the crossdomain policy request. 1 Answer

OAuth for Twitter an Facebook connect 3 Answers

WWW zero sized post buffer error Standalone 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges