WLive 4.0.0.4

This is framework for Windows Live.

Install-Package WLive -Version 4.0.0.4
dotnet add package WLive --version 4.0.0.4
<PackageReference Include="WLive" Version="4.0.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WLive --version 4.0.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Some example how to work with this framework is described on this site: http://wlivefw.codeplex.com/

Project has been on codeplex and I move it to GitHub now.

How to connect to Windows Live

There is class Connection for connection to Windows Live. You need client_id and client_secrect which you will get when you will register your application in MS site. There are static properties:

Connection.client_id = client_id;
Connection.client_secret = client_secret;
Connection.redirect_uri = redirect_uri; // I set this to "https://login.live.com/oauth20_desktop.srf";
Connection.connection = new Connection(); //created object connection
Connection.Expired += Connection_Expired; //set this for information when access token expired

There is Connection.code property. How to give code for login is describe on this page: https://msdn.microsoft.com/en-us/library/hh826543.aspx?f=255&MSPPError=-2147217396

If you have refresh token, you can set property Connection.connection.refresh_token. If this property is set it has higher priority than code property.

If you have set this properties you can call Connection.Login(); method. This metod will login into Windows Live.

There is method which refer to Connection.Expired event. When access token expires event is fired and you can login again to renew acces token.

private void Connection_Expired(object sender, EventArgs e)
{
Connection.Login();
}

Now you are login in.
How to upload file into Onedrive

There is class File in WLiveObjects namespace. This class has static method Create(T fileobj, Stream file, OverWriteOption owoption, RequestProgressHandler handler).
T is File object to give name and description
file is Stream to file which you want to upload
owoption is OverWriteOption which sais if you want to create new file when it exists on Onedrive, or you want to overwrite it or nothing
handler is delegate for feedback method

RequestProgressHandler handler = new RequestProgressHandler();
handler.ProgressChange += UploadProgress;

Create(file, fs, option, handler);

It will be better encapsulated in try catch block. There could be exception type of BITSException. This type of exception has method Continue. It is very easy to continue in upload when connection was broken by this method. Calling is simple:

((BITSException)exception).Continue((BITSException)exception); //exception object is parameter of method.

It could be very simple in code:

File fresult=null;
try
{
fresult = File.Create(file, fs, option, handler);
}
catch(BITSException e)
{
BITSException bex = e;
do
{
bool error = false;
try
{
bex.Continue(bex);
}
catch(BITSException b)
{
bex = b;
bex.Continue(bex);
error = true;
}
}while(error);
fresult = (File)bex.Result;
}

There is method which refer to delegate in handler. When there is change in upload progress upload mechanism will call this method by handler.ProgressChange(int bytes transfered, double percent)

void UploadProgress(int bytes, double proc)
{
Console.WriteLine(“{0};{1}”proc, bytes);
}

Some example how to work with this framework is described on this site: http://wlivefw.codeplex.com/

Project has been on codeplex and I move it to GitHub now.

How to connect to Windows Live

There is class Connection for connection to Windows Live. You need client_id and client_secrect which you will get when you will register your application in MS site. There are static properties:

Connection.client_id = client_id;
Connection.client_secret = client_secret;
Connection.redirect_uri = redirect_uri; // I set this to "https://login.live.com/oauth20_desktop.srf";
Connection.connection = new Connection(); //created object connection
Connection.Expired += Connection_Expired; //set this for information when access token expired

There is Connection.code property. How to give code for login is describe on this page: https://msdn.microsoft.com/en-us/library/hh826543.aspx?f=255&MSPPError=-2147217396

If you have refresh token, you can set property Connection.connection.refresh_token. If this property is set it has higher priority than code property.

If you have set this properties you can call Connection.Login(); method. This metod will login into Windows Live.

There is method which refer to Connection.Expired event. When access token expires event is fired and you can login again to renew acces token.

private void Connection_Expired(object sender, EventArgs e)
{
Connection.Login();
}

Now you are login in.
How to upload file into Onedrive

There is class File in WLiveObjects namespace. This class has static method Create(T fileobj, Stream file, OverWriteOption owoption, RequestProgressHandler handler).
T is File object to give name and description
file is Stream to file which you want to upload
owoption is OverWriteOption which sais if you want to create new file when it exists on Onedrive, or you want to overwrite it or nothing
handler is delegate for feedback method

RequestProgressHandler handler = new RequestProgressHandler();
handler.ProgressChange += UploadProgress;

Create(file, fs, option, handler);

It will be better encapsulated in try catch block. There could be exception type of BITSException. This type of exception has method Continue. It is very easy to continue in upload when connection was broken by this method. Calling is simple:

((BITSException)exception).Continue((BITSException)exception); //exception object is parameter of method.

It could be very simple in code:

File fresult=null;
try
{
fresult = File.Create(file, fs, option, handler);
}
catch(BITSException e)
{
BITSException bex = e;
do
{
bool error = false;
try
{
bex.Continue(bex);
}
catch(BITSException b)
{
bex = b;
bex.Continue(bex);
error = true;
}
}while(error);
fresult = (File)bex.Result;
}

There is method which refer to delegate in handler. When there is change in upload progress upload mechanism will call this method by handler.ProgressChange(int bytes transfered, double percent)

void UploadProgress(int bytes, double proc)
{
Console.WriteLine(“{0};{1}”proc, bytes);
}

Release Notes

This release (4.0.0.4) is stable and can be used to work with Windows Live. Functions of framework are focused to working with Onedrive (other objects are implemented so but there may not be some functions) but source codes are avalaible and this framework can be applied to other objects of Windows Live.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
4.0.0.4 537 10/1/2017