none
OneDrive + Winforms: Single Sign On for indefinite period (or close enough). Microsoft account authentication RRS feed

  • Question

  • Hello all, 

     I cannot find a definitive answer on the interwebs, though the implication seems to be not in my favour. Basically, I've got a winforms application, which will be used once in a while by a user. It's a utility style program so use is sporadic. The program produces a file which I wish to upload to the current signed in user's onedrive (microsoft account linked with windows). I've read that I can get the user to log in via a web browser control then store a OAuth token which lasts upto an hour, but I would  have to refresh every hour, which I cannot do, as my program is used sporadically. The user experience would be awful if they had to log frequently to authenticate. Like WinRT/store style apps, or what ever they are called, can the user allow my winforms desktop app access to their Microsoft Account, which they used to log into windows with, and upload to that account's onedrive?

    Thanks

    Tommy


    2010: Q6700 3GHz; 6GB DDRII; ~ 2.7TB internal; ATI RAEDON 5770 1GB @ Stock; Elixir Keyboard; Gigabyte GM-M6800; 2 x E173FPf 2005: 2GIG RAM, 3.6Ghz P4, 2 x 200gb SATA HD 8mb cache, 256mb 9950 ATI RADEON,19" LCD Core i7 3.2GHz, 6GB DDRIII, ASUS 512MB EN8800GT

    • Moved by Fred Bao Wednesday, February 18, 2015 3:34 AM WinForm Related
    • Moved by Sheng Jiang 蒋晟 Friday, February 20, 2015 7:27 PM More about System.Net
    Tuesday, February 17, 2015 6:58 AM

All replies

  • You need to get them to authorise.

    http://www.codeguru.com/columns/dotnet/authenticating-a-onedrive-account.html

    Unless they install the windows app and you save to their sync folder.

    But that kind of blows the point of using onedrive for most scenarios I can image.

    If they only use it sporadically, how come they're signing in frequently?

    I would have thought they choose to use your app.

    It says gimme your credentials.

    They input their ms account stuff.

    It does it's thing.

    If a session is potentially going to last longer than an hour you can save their input and re-authenticate as a background task.

    It's rest friendly so there's a web api takes username and password.

    You can call that from winforms.


    Hope that helps.
    Recent Technet articles: Property List Editing ;   Dynamic XAML

    Tuesday, February 17, 2015 8:20 AM
  • Thanks for your reply.

    Unless they install the windows app and you save to their sync folder.

    You mean OneDrive windows app?

    I want them to "install my winforms app", but how does that help? I want them to give my app permission to use onedrive... is there a way to do this like in WinRT style apps where you only need to grant it once. Ideally I want to link it with their MS account. Yes, I could save their credentials and re authenticate every time secretly, but that's less than ideal. 

    If they only use it sporadically, how come they're signing in frequently?

    What do you mean? My concern is that they will have to sign in frequently they only use the app sporadically. That is the app wont be running (not in memory).

    Thanks

    Thomas


    2010: Q6700 3GHz; 6GB DDRII; ~ 2.7TB internal; ATI RAEDON 5770 1GB @ Stock; Elixir Keyboard; Gigabyte GM-M6800; 2 x E173FPf 2005: 2GIG RAM, 3.6Ghz P4, 2 x 200gb SATA HD 8mb cache, 256mb 9950 ATI RADEON,19" LCD Core i7 3.2GHz, 6GB DDRIII, ASUS 512MB EN8800GT

    Wednesday, February 18, 2015 2:05 AM
  • Hello mrthomas,

    Since this issue is related with windows from, i move it to the windows form forum. The current forum you posted to is used to discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, February 18, 2015 3:39 AM
  • Maybe you are looking for this http://stackoverflow.com/questions/23825964/how-to-use-onedrives-api-in-desktop-app-and-remember-permission.

    remember make the reply as answer and vote the reply as helpful if it helps.

    Wednesday, February 18, 2015 6:25 AM
  • Thanks for the link, interesting, but do you know for a fact if it works? It talks of a refresh token, but is this indefinately? Any idea for winforms, as I've since read the first answer to this question on SO:

    http://stackoverflow.com/questions/24407954/how-to-do-authentication-onedrive-for-business-and-upload-a-file-winforms

    However, from the android sample code you sent and a quick riffle through https://github.com/liveservices/LiveSDK-for-Android/blob/master/src/src/com/microsoft/live/LiveAuthClient.java, I'm still in a state of flux as to whether this is possible or not for non-Window Store style apps (e.g. WinForms). There is no definitive answer on this.

    Thanks


    2010: Q6700 3GHz; 6GB DDRII; ~ 2.7TB internal; ATI RAEDON 5770 1GB @ Stock; Elixir Keyboard; Gigabyte GM-M6800; 2 x E173FPf 2005: 2GIG RAM, 3.6Ghz P4, 2 x 200gb SATA HD 8mb cache, 256mb 9950 ATI RADEON,19" LCD Core i7 3.2GHz, 6GB DDRIII, ASUS 512MB EN8800GT

    Wednesday, February 18, 2015 7:48 AM
  • Thanks for the link, interesting, but do you know for a fact if it works? It talks of a refresh token, but is this indefinately? Any idea for winforms, as I've since read the first answer to this question on SO:

    http://stackoverflow.com/questions/24407954/how-to-do-authentication-onedrive-for-business-and-upload-a-file-winforms

    However, from the android sample code you sent and a quick riffle through https://github.com/liveservices/LiveSDK-for-Android/blob/master/src/src/com/microsoft/live/LiveAuthClient.java, I'm still in a state of flux as to whether this is possible or not for non-Window Store style apps (e.g. WinForms). There is no definitive answer on this.

    Thanks


    2010: Q6700 3GHz; 6GB DDRII; ~ 2.7TB internal; ATI RAEDON 5770 1GB @ Stock; Elixir Keyboard; Gigabyte GM-M6800; 2 x E173FPf 2005: 2GIG RAM, 3.6Ghz P4, 2 x 200gb SATA HD 8mb cache, 256mb 9950 ATI RADEON,19" LCD Core i7 3.2GHz, 6GB DDRIII, ASUS 512MB EN8800GT

    One is C# and the other is Java, I don't think that makes any sense to compare with them.

    The most important tip is there is not such built-in api supported by winform because it is actually somehow web issue, we need to use the other api to get that work.

    I don't know whether that works or not, but that should be proved since the poster of the first thread have got that working.


    remember make the reply as answer and vote the reply as helpful if it helps.

    Thursday, February 19, 2015 3:07 AM
  • I miss a little bit why the Windows Forms part in your question is so important. 

    I've the idea that the problem is the same for WPF, Phone and every other kind of user interface, 

    Can you elaborate that a little bit for us. 

    For me it is just C# code and the right types which can be used in that. 

    Try to avoid the words Windows Forms, or pictures which show a windows form in forums.

    The first thing non Microsoft moderators seems to do is move it to this forum. If it are Microsoft moderators they do it after one day if they see it is not marked as answer.

    I'm delighted by the trust about the contributors in this forums. But it is not good if that means that this forum becomes a kind of thrash bin.


    Success
    Cor


    • Edited by Cor Ligthert Thursday, February 19, 2015 10:31 AM
    Thursday, February 19, 2015 10:29 AM
  • I am moving the thread to the System.Net forum, the closest forum I can find for this problem, however the Official community link on OneDrive Developer Center goes to http://stackoverflow.com/questions/tagged/onedrive so you should ask on stackoverflow for this question . Keep in mind your thread may be closed there if deemed as a duplicate, so make sure to explain why the accepted answers there did not work for you.


    Visual C++ MVP

    Friday, February 20, 2015 7:33 PM