locked
BackgroundUploader and oauth RRS feed

  • Question

  • I'm trying to set the oauth headers to upload files.

    If I used the HTTP Client  it works

    When I try the background upload it fails

    I'm doing ... 

      BackgroundUploader uploader = new BackgroundUploader();
    
                // uploader.SetRequestHeader("Filename", file.Name);
    
                var headerParams = OAuthUtility.BuildBasicParameters(
                    Domain.Super.Current.ConsumerKey
                    , Domain.Super.Current.ConsumerSecret
                    , uri.OriginalString, HttpMethod.Post, Domain.Super.Current.Token);
    
    
    
                var header = headerParams.Select(p => p.Key + "=" + p.Value.Wrap("\"")).ToString(",");
                uploader.Method = "POST";
    
                List<BackgroundTransferContentPart> parts = new List<BackgroundTransferContentPart>();
                var part = new BackgroundTransferContentPart("filename", file.Name);
                part.SetFile(file);
                parts.Add(part);
                part = new BackgroundTransferContentPart("name");
                part.SetText(file.Name);
                parts.Add(part);
                part = new BackgroundTransferContentPart("Content-Disposition");
                part.SetText("form-data");
                parts.Add(part);
                uploader.SetRequestHeader("Authorization", "Oauth " + header);
    
                UploadOperation upload = await uploader.CreateUploadAsync(uri, parts);   //.CreateUpload(uri, file);
    

    If I look with fiddler the header goes .. and seams ok ...

    any got this working ?


    cmorgado

    Monday, January 27, 2014 8:47 PM

Answers

  • Hi!

    I've fixed it earlier .. 

    the trouble was that the header is ... OAuth and not Oauth as I was doing.


    cmorgado

    Wednesday, January 29, 2014 9:53 AM

All replies

  • Are you saying that the requests that go through are the same in both cases?  If so, are you receving the same responses, or are there any different exceptions occurring?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, January 28, 2014 8:05 PM
    Moderator
  • Hi!

    I've fixed it earlier .. 

    the trouble was that the header is ... OAuth and not Oauth as I was doing.


    cmorgado

    Wednesday, January 29, 2014 9:53 AM