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
0
Question by nopogo · Mar 01, 2013 at 11:06 AM · wwwformbasicauthentication

login with basic auth gives 403 FORBIDDEN

When visiting the url, I get a basic-auth prompt, fill in the exact same username and password as typed in the code. And I successfully login. When trying the same with unity I get the following error:

You are trying to load data from a www stream which had the following error when downloading. 403 FORBIDDEN

I know I'm on the right track because before I would get 401 authorization required. The server is an ubuntu 12.04 with apache2.

 void LoginUser(string enteredUsername, string enteredPassword){
         encryptedPassword = md5(enteredPassword);
 
         WWWForm form = new WWWForm();
         form.AddField("our_username", enteredUsername);
         form.AddField("our_password", encryptedPassword);
         rawData = form.data;
 
         Hashtable header = new Hashtable();
         header = form.headers;
 
         header.Add("Authorization", "Basic " + System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("username:password")));
         www = new WWW(url, rawData, header);
 
         StartCoroutine(WaitForRequest(www));
         
         // Application.LoadLevel("Game");
         
     }
     
     
     IEnumerator WaitForRequest(WWW www){
         
         yield return www;
         Debug.Log(www.text);
         
         // check for errors
         if (www.error == null){
             Debug.Log("WWW Ok!: " + www.text);
         } else {
             Debug.Log("WWW Error: "+ www.error);
         }    
     }  
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
0
Best Answer

Answer by Graham-Dunnett · Mar 01, 2013 at 11:22 AM

Wikipedia tells me that the headers need to have colons after the names of each header. Try that and see if it solves the problem. (And try using something like Poster for Firefox. It'll let you create requests and POST them, which is a pretty easy way to figure out exactly what needs to be sent. Once you have a successful POST then you can implement the same in Unity.)

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 nopogo · Mar 01, 2013 at 12:05 PM 0
Share

Golden tip!, with poster I noticed the server gave me a very specific error (CSRF token protection) so I was able to fix it, I also updated the code to fix the headers

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

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

WWW class with authentication 0 Answers

Caching AssetBundle downloaded previously without using WWW.LoadFromCacheOrDownload 0 Answers

De- and Re- activating Unity 0 Answers

Augmented Reality in Unity Basic 1 Answer

How to use GameObject like Button? 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