<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Windows 8 store app Dropbox get access token and upload issue in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125134#M3659</link>
    <description>&lt;P&gt;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 uploading file in the dropbox using api.  Please give me the solution. &lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 09:44:05 GMT</pubDate>
    <dc:creator>karikalan</dc:creator>
    <dc:date>2019-05-29T09:44:05Z</dc:date>
    <item>
      <title>Windows 8 store app Dropbox get access token and upload issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125134#M3659</link>
      <description>&lt;P&gt;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 uploading file in the dropbox using api.  Please give me the solution. &lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:44:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125134#M3659</guid>
      <dc:creator>karikalan</dc:creator>
      <dc:date>2019-05-29T09:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Windows 8 store app Dropbox get access token and upload issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125135#M3660</link>
      <description>&lt;P&gt;Moved to the API forum.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2015 20:03:47 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125135#M3660</guid>
      <dc:creator>Rich</dc:creator>
      <dc:date>2015-03-27T20:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Windows 8 store app Dropbox get access token and upload issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125136#M3661</link>
      <description>&lt;P&gt;Please share your code: specifically the part where you make the call to exchange the request token for an access token.&lt;/P&gt;

&lt;P&gt;From the terminology "request token," it sounds like maybe you're using OAuth 1? Are you using a library for OAuth, or are you writing your own code? Which signing method are you using? (HMAC-SHA1 or PLAINTEXT?)&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2015 22:10:58 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125136#M3661</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2015-03-27T22:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Windows 8 store app Dropbox get access token and upload issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125137#M3662</link>
      <description>&lt;P&gt;We are using the following code and using OAuth1 and  HMAC-SHA1 signing method.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var authentication = new Authentication(AppKey, AppSecret);
var token = await authentication.RequestToken("https://api.dropbox.com/1/oauth/request_token", WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString());

if (token != null)
{
    var url = "https://www.dropbox.com/1/oauth/authorize?oauth_token=" + token.Key + "&amp;amp;oauth_callback=" + WebAuthenticationBroker.GetCurrentApplicationCallbackUri();
    System.Uri StartUri = new Uri(url);

    WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(
                                            WebAuthenticationOptions.None,
                                            StartUri);
    if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
    {

        authentication.GetAccessToken("https://api.dropbox.com/1/oauth/access_token?oauth_token=" + token.Key, token.Key, token.Secret);
        Upload();
    }

public async static void Upload()
{
    var picker = new Windows.Storage.Pickers.FileOpenPicker();
    picker.FileTypeFilter.Add(".jpg");
    picker.FileTypeFilter.Add(".png");
    picker.FileTypeFilter.Add(".gif");
    picker.FileTypeFilter.Add(".doc");
    picker.FileTypeFilter.Add(".docx");
    picker.FileTypeFilter.Add(".xls");

    StorageFile attachmentFile = await picker.PickSingleFileAsync();
    byte[] imgBytes = await GetPhotoBytesAsync(attachmentFile);

    string apiKey ="yvynusucnu104zf" ;

    string consumerSecret = "&amp;lt;redacted&amp;gt;";
    string tokenKey = "vam1o365ldgp4wf7";

    TimeSpan SinceEpoch = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());
    Random Rand = new Random();

    Int32 Nonce = Rand.Next(1000000000);

    var uri = new Uri(new Uri("https://api-content.dropbox.com/1/"),
        String.Format("files_put/{0}/{1}",
        "dropbox", @"Photos\car-acc2.jpg"));

    var requestUri = SignRequest(uri, apiKey, consumerSecret, tokenKey, "PUT");
    HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(requestUri);
    Request.Method = "PUT";

    //Request.Headers["Authorization"] = Data;



    using (Stream requestStream = await Request.GetRequestStreamAsync())
    {
        await requestStream.WriteAsync(imgBytes, 0, imgBytes.Length);
        await requestStream.FlushAsync();
    }

    HttpWebResponse Response = (HttpWebResponse)await Request.GetResponseAsync();
    StreamReader ResponseDataStream = new StreamReader(Response.GetResponseStream());

}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Apr 2015 17:23:39 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125137#M3662</guid>
      <dc:creator>karikalan</dc:creator>
      <dc:date>2015-04-07T17:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Windows 8 store app Dropbox get access token and upload issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125138#M3663</link>
      <description>&lt;P&gt;What's the exact URL you're hitting when you get the 401? (Please X out any secrets in the URL.)&lt;/P&gt;

&lt;P&gt;Note that the app key in your code snippet below is for a disabled app. (That would certainly cause a 401.)&lt;/P&gt;

&lt;P&gt;If you can get the actual body for the 401 response, that would help.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 04:40:44 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125138#M3663</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2015-04-08T04:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Windows 8 store app Dropbox get access token and upload issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125139#M3664</link>
      <description>&lt;P&gt;I have used the following url, app key, app secret and data which has posted to retrieve the access token.&lt;/P&gt;

&lt;P&gt;URL: &lt;A href="https://api.dropbox.com/1/oauth/access_token?oauth_token=KDIGaDoXjQBvT0pn" rel="nofollow noreferrer"&gt;https://api.dropbox.com/1/oauth/access_token?oauth_token=KDIGaDoXjQBvT0pn&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;AppKey = "qas1ok71ay8wqr0"&lt;BR /&gt;
AppSecret = "&amp;lt;REDACTED&amp;gt;"&lt;/P&gt;

&lt;P&gt;Posted Data : &lt;CODE&gt;OAuth oauth_consumer_key="qas1ok71ay8wqr0", oauth_nonce="300571600", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1428469092", oauth_version="1.0", oauth_signature="tJTlNcaoYq6J01FwOjflR8s37P8%3D"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;GetAccess Token Method Code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;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 += "&amp;amp;" + "oauth_nonce=" + Nonce.ToString();
    sigBaseStringParams += "&amp;amp;" + "oauth_signature_method=HMAC-SHA1";
    sigBaseStringParams += "&amp;amp;" + "oauth_timestamp=" + Math.Round(SinceEpoch.TotalSeconds);       
    sigBaseStringParams += "&amp;amp;" + "oauth_version=1.0";
    String SigBaseString = "POST&amp;amp;";
    SigBaseString += Uri.EscapeDataString(url) + "&amp;amp;" + 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&amp;lt;string&amp;gt; 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();

}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2015 12:22:23 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125139#M3664</guid>
      <dc:creator>karikalan</dc:creator>
      <dc:date>2015-04-08T12:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Windows 8 store app Dropbox get access token and upload issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125140#M3665</link>
      <description>&lt;P&gt;I see two immediate issues:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Your &lt;CODE&gt;Authorization&lt;/CODE&gt; header on the call to &lt;CODE&gt;/access_token&lt;/CODE&gt; seems to be missing the required parameter &lt;CODE&gt;oauth_token&lt;/CODE&gt;. You seem to have it in the URL instead, which I don't &lt;EM&gt;think&lt;/EM&gt; works. (I don't think you can mix parameters in the query string and in the &lt;CODE&gt;Authorization&lt;/CODE&gt; header.)&lt;/LI&gt;
&lt;LI&gt;You're escaping the signature, which causes it to be invalid Base64. (It ends with &lt;CODE&gt;%3D&lt;/CODE&gt; instead of &lt;CODE&gt;=&lt;/CODE&gt;.)&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Also, I removed your app secret from your post, but others may have seen the post while it was visible, so you should consider it to be leaked.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 12:29:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125140#M3665</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2015-04-08T12:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Windows 8 store app Dropbox get access token and upload issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125141#M3666</link>
      <description>&lt;P&gt;Thanks for your reply. Still getting 401 unauthorized error even after passing oAuth token and  removing escape data string in signature. But same code working fine in console appo&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2015 11:35:18 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125141#M3666</guid>
      <dc:creator>karikalan</dc:creator>
      <dc:date>2015-04-09T11:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Windows 8 store app Dropbox get access token and upload issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125142#M3667</link>
      <description>&lt;P&gt;Would you please share your updated code?&lt;/P&gt;

&lt;P&gt;If you have two apps and one is working, I would suggest comparing the two to see what differences there are.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2015 00:36:13 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125142#M3667</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2015-04-10T00:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Windows 8 store app Dropbox get access token and upload issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125143#M3668</link>
      <description>&lt;P&gt;The code is not working only in WINRT store app. do you have any sample code to get the access token in the win RT Store app?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2015 12:02:17 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125143#M3668</guid>
      <dc:creator>karikalan</dc:creator>
      <dc:date>2015-04-10T12:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Windows 8 store app Dropbox get access token and upload issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125144#M3669</link>
      <description>&lt;P&gt;I published &lt;A href="https://blogs.dropbox.com/developers/2014/04/dropbox-authorization-in-a-windows-store-app/" rel="nofollow noreferrer"&gt;https://blogs.dropbox.com/developers/2014/04/dropbox-authorization-in-a-windows-store-app/&lt;/A&gt; last year. It uses OAuth 2, though.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2015 12:09:57 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Windows-8-store-app-Dropbox-get-access-token-and-upload-issue/m-p/125144#M3669</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2015-04-10T12:09:57Z</dc:date>
    </item>
  </channel>
</rss>

