• 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 Mark Simpson · Jan 28, 2011 at 06:23 PM · webplayerwwwauthenticationhttpsheaders

https -- works in IDE & Standalone, does not work in web browser

Context

I'm doing some work that involves calling into foursquare's API which requires HTTPS basic auth to get certain information.

We've previously done some work like this before, but it didn't involve unity. In the past with standard .NET (no Unity3D/Mono), we just created a standard web request, encoded the username and password and added it to the request header -- it all worked fine.

Enter Unity3D and the WWW class

However, since there's no way to programmatically set HTTP headers using the WWW class while doing a GET (correct me if I'm wrong) and we must run in the web player, I just did something like the following as a stopgap:

private static string CreateBaseUrl(string _username, string _password)
{
    return string.Format("{0}{1}:{2}@{3}", "https://", WWW.EscapeURL(_username), WWW.EscapeURL(_password), "api.foursquare.com/");
}

I then use this as my base url for accessing foursquare, then tack on the request information as you'd expect. E.g.:

public WWW RequestFullVenueDetails(VenueId _id)
{
    string url = string.Format("{0}{1}?vid={2}", m_baseUri, VenueUri, _id.Value);
    return new WWW(url);
}

In a standalone build and when running from the IDE it functions perfectly. I get back information about my foursquare account that requires authentication. For example, there is a "beenhere" value that tells you whether the authed account has ever checked into a venue.

The Web Player...

However, when I run it in the web player, the calls appear to work fine, but I don't get any of the extra information that should be returned when authenticated (i.e. it's behaving like an unauthenticated request, so the "have I been here?" data is missing, amongst other things).

When I examine the output using fiddler, it says the request has no auth header. If I deliberately enter an incorrect password, the request will return an error, so I don't understand why it's failing to return the data that requires authentication since my username and password must be correct.

Does anyone have any idea why the web player is behaving differently and what I can do to fix the problem? This is just rough and ready experimentation so I'd rather not have to figure out how to use OAuth or anything more complicated for the moment.

Possibly related: WWW support is broken

Cheers.

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

Answer by Simon Wittber · Mar 03, 2011 at 02:40 AM

UnityWeb might help you. It now supports HTTPS.

Comment
Add comment · 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

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

How to avoid reestablishing an HTTPS request, use Connection: Keep-Alive or reuse WWW object? 2 Answers

WWW Request runs in Editor but not in Webplayer 1 Answer

WWW POST request headers gone on webplayer facebook 1 Answer

Here's how I used Django to do User Auth in Unity3d 0 Answers

www not working on android and iOS 0 Answers


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