• 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
Question by TwistedSage · May 20, 2017 at 04:27 PM · dropbox

Anyone tried to integrate dropbox in unity?

Hi. I got a complete implementation of dropbox login/upload/download through their REST API and Unitys build in WebRequest function.

The only thing not working is the authentication and Dropbox are not exactly getting back to me. The problem is:

  • User authenticates app through OAuth 2 and I get a correct key back.

  • Now I want to trade the key for an access token and I get an error 500 (server error).

So while I wait for dropbox support (been waiting 3 weeks now), did anyone make this work in unity? (They did answer that they can't see what's wrong)

Thanks in advance

Odin

Comment
immerVR

People who like this

1 Show 2
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 dblincoeii · Feb 03, 2018 at 03:11 AM 0
Share

@TwistedSage Wondering if you found a method for doing this? Looking myself.

avatar image immerVR · May 19 at 08:12 PM 0
Share

Anyone got this to work? @TwistedSage , would it be possible to get a sample on the login through REST you did in Unity?

1 Reply

  • Sort: 
avatar image

Answer by SteenPetersen · May 19 at 08:17 PM

@TwistedSage - don't if you're still looking for an answer, but given that a few people have been asking if you got this to work I thought I'd place a a possible solution here.

Given that you're encountering an error 500 when trying to exchange the OAuth 2 key for an access token, it's possible that the issue may be with how you're making the request to Dropbox's API. A 500 error typically indicates that something went wrong on the server side, but this could also be due to the server not understanding the request.

You could exchange the OAuth 2 authorization code for an access token in Unity using the UnityWebRequest class (warning untested):

 string authorizationCode = "<Your Authorization Code>";
 string clientId = "<Your Client ID>";
 string clientSecret = "<Your Client Secret>";
 string redirectUri = "<Your Redirect URI>";
 
 Dictionary<string, string> headers = new Dictionary<string, string>();
 headers.Add("Content-Type", "application/x-www-form-urlencoded");
 headers.Add("Authorization", "Basic " + System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(clientId + ":" + clientSecret)));
 
 WWWForm form = new WWWForm();
 form.AddField("code", authorizationCode);
 form.AddField("grant_type", "authorization_code");
 form.AddField("redirect_uri", redirectUri);
 
 UnityWebRequest www = UnityWebRequest.Post("https://api.dropbox.com/1/oauth2/token", form.data, headers);
 yield return www.SendWebRequest();
 
 if (www.isNetworkError || www.isHttpError)
 {
     Debug.Log(www.error);
 }
 else
 {
     Debug.Log("Access Token: " + www.downloadHandler.text);
 }


This script is attempting to POST the request to Dropbox's token endpoint with the appropriate headers and body parameters.

If the issue persists, post the error response body here to provide some additional information that might help pinpoint the problem. It could be that the OAuth 2 key is not valid or that the request body is not formatted correctly.

Comment

People who like this

0 Show 0 · 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

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

How to save game in a dropbox hosted unity web app? 1 Answer

I saved a scene into Dropbox, and when I download the Scene from Dropbox, its all blank!?! 2 Answers

How do I upload a game to dropbox? 2 Answers

Downloading files from Dropbox 2 Answers

Play on Weebly, host on Dropbox, won't pass install web player 2 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