We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
karikalan
11 years agoNew member | Level 1
Windows 8 store app Dropbox get access token and upload issue
I am able to successfully login and get the request token using rest apin in Windows 8 store app. But I am getting '401 Unauthorized' error while retrieving the access token as well as trying to upl...
karikalan
11 years agoNew member | Level 1
I have used the following url, app key, app secret and data which has posted to retrieve the access token.
URL: https://api.dropbox.com/1/oauth/access_token?oauth_token=KDIGaDoXjQBvT0pn
AppKey = "qas1ok71ay8wqr0"
AppSecret = "<REDACTED>"
Posted Data : OAuth oauth_consumer_key="qas1ok71ay8wqr0", oauth_nonce="300571600", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1428469092", oauth_version="1.0", oauth_signature="tJTlNcaoYq6J01FwOjflR8s37P8%3D"
GetAccess Token Method Code:
public async void GetAccessToken(string url, string key, string secret)
{
TimeSpan SinceEpoch = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());
Random Rand = new Random();
Int32 Nonce = Rand.Next(1000000000);
String sigBaseStringParams = "oauth_consumer_key=" + _apiKey;
sigBaseStringParams += "&" + "oauth_nonce=" + Nonce.ToString();
sigBaseStringParams += "&" + "oauth_signature_method=HMAC-SHA1";
sigBaseStringParams += "&" + "oauth_timestamp=" + Math.Round(SinceEpoch.TotalSeconds);
sigBaseStringParams += "&" + "oauth_version=1.0";
String SigBaseString = "POST&";
SigBaseString += Uri.EscapeDataString(url) + "&" + Uri.EscapeDataString(sigBaseStringParams);
var signature = GenerateSignature(SigBaseString, secret);
String DataToPost = "OAuth oauth_consumer_key=\" + _apiKey + "\", oauth_nonce=\" + Nonce.ToString() + "\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\" + Math.Round(SinceEpoch.TotalSeconds) + "\", oauth_version=\"1.0\", oauth_signature=\" + Uri.EscapeDataString(signature) + "\";
var postResponse = await PostData(url, DataToPost);
}
private async Task<string> PostData(String Url, String Data)
{
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(Url);
Request.Method = "POST";
Request.Headers["Authorization"] = Data;
HttpWebResponse Response = (HttpWebResponse)await Request.GetResponseAsync();
StreamReader ResponseDataStream = new StreamReader(Response.GetResponseStream());
return ResponseDataStream.ReadToEnd();
}
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!