Git Product home page Git Product logo

box-windows-sdk-v2's Introduction

“box-dev-logo”

Deprecation notice

This version of the Box .NET SDK is under maintenance mode, and will be deprecated soon, only critical security updates and bug fixes will be provided. We recommend using the new version Box .NET SDK, which can be found at box/box-dotnet-sdk-gen

You can find the migration guide here for transitioning from Box .NET SDK v5.x to the new box-sdk-gen package. If you have any questions, please create an issue in the new repository or reach out to Box Developer Support.

Box Windows V2 SDK

Project Status Platform Framework Platform Core License Build

The Box .NET SDK can be used to make API calls to the Box APIs in a .NET project.

The SDK is available for both .NET Framework 4.6.2 and .NET Core 2.0 or above. The installation of the SDK depends on the platform used.

Table of contents

Getting Started

Installation

You can install SDK library using Nuget

If you want to use .NET Core

PM> Install-Package Box.V2.Core

If you want to use .NET Framework

PM> Install-Package Box.V2

Or you can add it to your project directly in Visual Studio.

You can also download latest version from our Github's release page

Authentication

Our .NET SDK supports the following authentication methods:

Sample apps

You can check one of our sample apps included in this repository to see how to use the SDK

Usage

You can find detailed usage documentation and code samples under docs directory.

Other resources

Versions

We use a modified version of Semantic Versioning for all changes. See version strategy for details which is effective from 30 July 2022.

Supported Version

Only the current MAJOR version of SDK is supported. New features, functionality, bug fixes, and security updates will only be added to the current MAJOR version.

A current release is on the leading edge of our SDK development, and is intended for customers who are in active development and want the latest and greatest features. Instead of stating a release date for a new feature, we set a fixed minor or patch release cadence of maximum 2-3 months (while we may release more often). At the same time, there is no schedule for major or breaking release. Instead, we will communicate one quarter in advance the upcoming breaking change to allow customers to plan for the upgrade. We always recommend that all users run the latest available minor release for whatever major version is in use. We highly recommend upgrading to the latest SDK major release at the earliest convenient time and before the EOL date.

Version schedule

Version Supported Environments State First Release EOL/Terminated
5 .NET Framework 4.6.2+ and .NET Core 2.0+ Supported 02 Nov 2021 TBD
4 .NET Framework 4.5+ and .NET Core 2.0+ EOL 02 Nov 2021 TBD
3 EOL 28 Jul 2017 02 Nov 2021
2 EOL 05 Nov 2015 28 Jul 2017

Migrating from the old version?

If you are migrating from the old major version visit our upgrade documentation.

Questions, Bugs, and Feature Requests?

Browse the issues tickets! Or, if that doesn't work, file a new one and someone will get back to you. If you have general questions about the Box API, you can post to the Box Developer Forum.

Contributing

All contributions to this project are welcome! For more information, please see our Contribution guidelines.

Copyright and License

Copyright 2018 Box, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

box-windows-sdk-v2's People

Contributors

alitaleg avatar antusus avatar arjankowski avatar box-sdk-build avatar brianytang avatar carycheng avatar cburnette avatar congminh1254 avatar coolboy avatar cpcrook avatar ephremshiferaw avatar friedrich-brunzema avatar kendomen avatar lukaszsocha2 avatar marek-vysoky avatar marekvysoky avatar matthewdickinson avatar mdestagnol avatar mgrytsai avatar mhagmajer avatar mwwoda avatar njsardo avatar nzakas avatar ohadschn avatar pjsimon avatar preciselyalyss avatar rod-sychev avatar rpalaniappan avatar sujaygarlanka avatar ultimoamore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

box-windows-sdk-v2's Issues

Error uploading files larger than 5MB

Example code used:
...
var task = boxClient.FilesManager.UploadAsync(boxFileRequest, fileStream));
BoxFile boxFile = task.Result;
...

If fileStream.Length > 5MB an error occurs:
ObjectDisposedException
ObjectName: System.Net.Sockets.Socket

(if fileStream.Length < 5MB - work fine)

OS: Windows Server 2008 R2 x64 (6.1.7601),
.NET Framework: v4.0.30319

Folder collaborations can be either BoxUser or BoxGroup but AccessiblyBy property is only type BoxUser; cast is failing

Basically when you get the collaborations on a folder the collaborations AccessibleBy properties can be either a BoxUser or a BoxGroup (groups can be collaborators). However, in the BoxCollaboration class the AccessibleBy property is of type BoxUser. Therefore when you ask for the collaborations of a folder that also has a group collaborated in, the SDK is unable to cast the BoxGroup object and set AccessibleBy. An exception is thrown during the deserialization.

///

    /// The user who the collaboration applies to
    /// </summary>


    [JsonProperty(PropertyName = FieldAccessibleBy)]
    public BoxUser AccessibleBy { get; set; }

​​​​From quickly looking at it we may just want to change the property to be of type BoxEntity and then as a user of the SDK you just have to figure out how to cast it if they need the data. Thoughts?

Issues with .Net 4.5 verison

Hey,
I'm using this SDK to build a server application, and the server supports only 4.5 framework. SDK looks for System.Threading.Tasks and System.Runtime(4.0 version dll) while build. And on building by 4.5 framework I get error that (System.Runtime) are already defined in mscorlib.dll (4.5).

Can you please provide me something that works with only .net 4.5 framework.

Windows 7 64-bit Visual Studio build issues

I'm trying to reference the Box.V2 library in a 64-bit library. The application I'm building is an add-on to a 64-bit application (Solidworks). This is requiring me to build a 64-bit library, but I'm having issues with deployment. The app works fine on my development machine, but I get file not found exceptions when I run on my 64-bit virtual machine.

Specifically, I'm having problems with Nito.AsyncEx. I suspect it's because I can't find a 64-bit version of that library, but I'm not sure. If anyone has suggestions or can recommend build settings, that would be fantastic.

Thanks.

JSON parser fails if collaboration having group

While fetching collaboration information of given folder id. It always throws excpetion {"Error setting value to 'AccessibleBy' on 'Box.V2.Models.BoxCollaboration'."}

Method which fails: public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)

Here is JSON string ( Parser fails)
jObject {
"type": "collaboration",
"id": "74331049",
"created_by": null,
"created_at": "2014-07-28T14:52:41-07:00",
"modified_at": "2014-07-28T14:52:41-07:00",
"expires_at": null,
"status": "accepted",
"accessible_by": {
"type": "group",
"id": "235821",
"name": "DevTeam"
},
"role": "editor",
"acknowledged_at": "2014-07-28T14:52:41-07:00",
"item": {
"type": "folder",
"id": "2233474793",
"sequence_id": "0",
"etag": "0",
"name": "XXX"
}
}

It seems parser does not handle case if "accessible_by" is of type "group"

Could not load file or assembly 'Nito.AsyncEx, Version=1.0.0.0...'

Hi there,

We've got the WCF project targeting .Net 4.0 under VS 2010 Win7 x64, please note that it is a signed assembly.
The Box.V2 SDK has been installed through NuGet and the version we are using is 1.0.5.

The bad things started to happen once we tried to build the solution, the first issue was with the Box.V2 dll itself where we couldn't go forward due to the following error:
"Assembly generation failed -- Referenced assembly 'Box.V2' does not have a strong name".
We've managed to overcome this one by signing the assembly using the 'Brutal Developer .NET Assembly Strong-Name Signer (1.3.0.0)'.

After it got successfully built we bumped into the second problem whereas creating a BoxClient would throw an exception with the following message:
"Could not load file or assembly 'Nito.AsyncEx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)".
We've used the code provided in the example aka:
var config = new BoxConfig(clientId, clientSecret, new Uri(redirectUri));
var client = new BoxClient(config);
where clientId, clinetSecret and redirectUri are the parameters of our method.

Steps taken to resolve the issue:

  1. Nito.AsyncEx dll was signed using the same aforementioned tool - same exception.
  2. Nito.AsyncEx assembly was upgraded to the latest version (2.1.3.0) where in fact they have tweaked it and used the strong name for their assemblies - still no luck.
  3. One of the issues submitted here (#3) had a similar problem and we've tried to follow the suggested scenario however it did not help much.
  4. We tried to not sign our assembly at all but again in vain as same exception was thrown.

So we are currently stuck deploying Box API in our product that is rather frustrating therefore if anyone has got any idea on how to get around this problem please give us a shout. Any help is greatly appreciated.

Amicus Attorney DEV team.

Box Windows SDK V2 1.1.2 released on Friday, August 08 2014

Could you please outline what has been changed/added in the new release of the SDK?
NuGet description is pretty poor (Auth repository enhancements).
What kind of enhancements?
What have you done to make the library usage easier and less prone to inadequate pitfalls?
I'm particularly curious about auth token management.
Thank you in advance.

Question on Using Refresh Token in Windows Box SDK

We are storing the refresh token in our SQL database after a user logs into BOX on our .NET web page. On a subsequent login, how can we use that refresh token?

Using AuthenticateAsync, it looks like it only takes the access code, and not an option to pass in a refresh token. How can I use the refresh token and avoid having the user log into BOX each time they access the page? Below is what we are using initially on their first log in.

var config = new Box.V2.Config.BoxConfig(BoxClientID, BoxClientSecret, uri);
var client = new BoxClient(config);
var session = client.Auth.AuthenticateAsync(AccessCode);
strRefreshToken = client.Auth.Session.RefreshToken;

Access token is not refreshing automatically or via RefreshAccessTokenAsync after 1 hour on Windows 8.1 C#?

Hi,

After one hour of authenticating with box my access token expired which is obvious. So first I tried calling RefreshAccessTokenAsync(accessToken) which gave me an exception : Box.V2.Exceptions.BoxException: invalid_grant: Refresh token has expired.
After that, I searched on forums and found out that we don't need to refresh the access token. The SDK automatically refreshes the access token when it finds a access token has been invalidated.
But I couldn't came to find out that the access token is automatically refreshed by box SDK. I started sync with box in the morning around 11 AM and also saved my access token in a notepad file to crosscheck with the new accesstoken and in the meantime, i was doing some work on the app and at around 4 i cross checked the latest access tokem with the previous one i saved in the notepad. No difference was there. My access token was not refreshed.

How to workaround this?
How to refresh the access token?

Thanks,
Abhishek Jindal

Issue in tag creation

Not able to create tag information on folders from the API.
Need help for this issue asap.

Compile time errors after installing Box

I have installed lates Box.V2 v1.1.4 NuGet package into my C# Class library project that has framework 4.0. After installing project I wrote below piece of code:

var boxConfig = new BoxConfig(clientId, clientSecret, RedirectUrl);
var boxClient = new BoxClient(boxConfig, null);
var oAuthSession = boxClient.Auth.AuthenticateAsync(authorizationCode).Result;

I have also referred appropriate Box namespaces in my class file. After compilation I get below error:

"The type or namespace name 'Box' could not be found (are you missing a using directive or an assembly reference?)"

Could you please help me to figure out the problem here?

Issues uploading large files to Box

I am facing 2 issues regarding Box file upload feature. I have a requirement of uploading movie files to box through my .NET application.

Issue 1:
I am able to upload files of size 250-300 MBs but it takes long time. It takes around 1.5-3 mins to upload. When I upload the file from Box (using their web interface), it takes less than a minute to upload files.
Why is there so much of difference when you upload file from API and from Box Web interface?

Issue 2:
I am not able to upload files of size 500 MBs or more. The requests timeouts. I have set the timeout as 10 mins but still the error is thrown. I believe 10 mins should be enough time to upload file of size 500 MBs. Again when I upload same file from Box (using their web interface), it takes around a minute to upload files.

I am using Box V2 SDK for windows. Visual studio 2010/2012. Any help in this regards is appreciated. Please let me know if any more info is needed.

Error in setting ID property using BoxEntity Class

When i am calling my webservice from my application at that time it gives me following error:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: Cannot deserialize type 'Box.V2.Models.BoxEntity' because it contains property 'Id' which has no public setter.

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: Cannot deserialize type 'Box.V2.Models.BoxEntity' because it contains property 'Id' which has no public setter.

at System.Xml.Serialization.TypeScope.GetSettableMembers(StructMapping mapping, ArrayList list)

at System.Xml.Serialization.TypeScope.GetSettableMembers(StructMapping mapping, ArrayList list)

at System.Xml.Serialization.TypeScope.GetSettableMembers(StructMapping mapping, ArrayList list)

at System.Xml.Serialization.TypeScope.GetSettableMembers(StructMapping structMapping)

at System.Xml.Serialization.TypeScope.GetSettableMembers(StructMapping mapping, Dictionary`2 memberInfos)

at System.Xml.Serialization.XmlSerializationReaderILGen.WriteLiteralStructMethod(StructMapping structMapping)

at System.Xml.Serialization.XmlSerializationReaderILGen.GenerateMethod(TypeMapping mapping)

at System.Xml.Serialization.XmlSerializationILGen.GenerateReferencedMethods()

at System.Xml.Serialization.XmlSerializationReaderILGen.GenerateEnd(String[] methods, XmlMapping[] xmlMappings, Type[] types)

at System.Xml.Serialization.TempAssembly.GenerateRefEmitAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence)

at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)

at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)

at System.Web.Services.Protocols.SoapServerType..ctor(Type type, WebServiceProtocols protocolsSupported)

at System.Web.Services.Protocols.SoapServerProtocol.Initialize()

at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

--- End of inner exception stack trace ---

When i tried to find rootcause of this problem i've found that BoxEntity class has no setter property defined for ID and Type.

anyone can help ??

User.Enterprise.Name property missing.

I wanted to get the name of the user's enterprise but found that the Enterprise reference in BoxUser is a BoxEntity which does not have a name property.

Groups

Hello. Now that the API supports groups, I was wondering if there is any plan for the SDK to be updated with this new functionality.

If so, any time frame?

Thanks!
John

Lock info & operations

I see there is no locking management in the SDK, while the API allows it.
I forked the project and got it somehow working; would it be a worthy addition?

I think the exceptions are being hided some core portion in BoxResponseExtensions.cs

I think the exceptions are being hidden by some code in \Box.V2\Extensions\BoxResponseExtensions.cs.

Here:

case ResponseStatus.Error:
    if (!string.IsNullOrWhiteSpace(response.ContentString))
    {
        try
        {
            response.Error = converter.Parse<BoxError>(response.ContentString);

            if (response.Error != null && !string.IsNullOrWhiteSpace(response.Error.Name))
                throw new BoxException(string.Format("{0}: {1}", response.Error.Name, response.Error.Description)) { StatusCode = response.StatusCode };
        }
        catch (Exception)
        {
            Debug.WriteLine(string.Format("Unable to parse error message: {0}", response.ContentString));
        }
    }
    throw new BoxException() { StatusCode = response.StatusCode };

" catch (Exception)" is hiding the true exception that was just thrown.
I mean, the thrown "throw new BoxException(string.Format("{0}: {1}",..." will be handled by the "catch (Exception)" and discarded.
Therefore just an empty "BoxException" returns to the the caller.

Provide Injectable Interface For Token Storage

Currently the SDK attempts to update access tokens when they expire however the client has no control over the storage of these tokens nor has the ability to be updated when the token is refreshed resulting in thread safety issues.

If we allow the client to provide an implementation to use when tokens are changed or updated, this would allow the client to control the token management but allow the SDK to abstract the complicity around token renewal.

Calling AuthenticateAsync from asp.net application

Hi,

I'm going through the OAuth workflow; I have successfully retrieved the Access Code from Box and now I'm attempting to retrieve Access and Refresh Tokens.

My function is as follows:

code

But as you can see I'm getting an error with 'await'.

My application's target framework is .NET 4.5.

Also, not sure if this is relevant, but when I click on 'Go To Definition' for the method I'm calling, it's going to AuthenticateAsync under IAuthRepository.cs (and not AuthRepository.cs)

Am I missing something?

Thanks!

Optional etag header in file operations

Hello,

There are several functions that allow for an optional etag value (New Version, Delete). However if you do not supply the etag, the function will throw an Argument Exception. Here is an example below:

    public async Task<bool> DeleteAsync(string id, string etag)
    {
        id.ThrowIfNullOrWhiteSpace("id");
        etag.ThrowIfNullOrWhiteSpace("etag");

        BoxRequest request = new BoxRequest(_config.FilesUploadEndpointUri, id)
            .Method(RequestMethod.Delete)
            .Header("If-Match", etag);

        IBoxResponse<BoxFile> response = await ToResponseAsync<BoxFile>(request).ConfigureAwait(false);

        return response.Status == ResponseStatus.Success;
    }

Should the etag.ThrowIfNullOrWhiteSpace("etag") be there? I feel as though that line should be removed.

Is long polling or any sort of polling supported?

Hello,

I am writing in order to get more information regarding the Box API precisely I need a way to track the changes that have been occurred in the particular users Box folder.
I am aware that there is the Event Notifications feature however this is not what I am looking for as instead of waiting for the event to occur I want to poll in the timely manner the particular folder in the user’s account to see what has changed and then react accordingly.
Please let me know if there is a way to do this.
Thanks you in advance for your cooperation.

Regards,
Rodion Sychev.

Wrong endpoint for BoxFolderManager.GetItemsAsync

GetItemsAsync and GetInformationAsync have the same endpoint and return the same data. According to the API docs GetItems should be calling /folders/{folder id}/items. Otherwise I don't see a way to to get specific fields of the children or to page through the children.

Also, I notice that the unit tests don't really assert anything. How are they actually testing results?

Setting description when uploading a new file

Hi - I am currently unable to set the description of a file when creating it. No error message is received and the file is successfully uploaded, but the description is empty.

If updating an existing file, setting of the description works just fine.

Screen shots below with code used.

Thanks for the help!

1-Upload file - does not set description
image

2-Update file - does set description
image

GetFolderItemsAsync BoxItems properties null

Hi, when I call the function GetFolderItemsAsync, the List returned by this function has all the properties in BoxItems like "CreatedBy", "ModifiedAt" are coming as null, the only properties that I can get is Id, Type, Name. any initial thoughts why this could happen?

Regards
HJ

How to get deleted items?

Is there a way to retrieve a list of items in the Trash?
I am aware about the FoldersManager.GetTrashItemsAsync and FoldersManager.GetTrashedFolderAsync however these methods are written in the way that I need to know the id of the folder/item to retrieve it however in my case I've got no knowledge about that and just want to grab all the deleted items preferably given the time boundaries, i.e. get all the deleted items from noon March 13th to noon March 14th.

Can this be achieved?

Any help is greatly appreciated.

about license

hi,
how about this code license . I can`t find any license here.

thanks a lot

'ModifiedAt' property is not changed when item is deleted

So when the item is moved to Trash folder it's 'ItemStatus' property is changed to "trashed" however 'ModifiedAt' property stays intact. I would expect it to be amended once item status is tweaked.
Is this a bug or "feature"?

BoxSDKKey.pfx missing

Hello there,

I was working on that bug in getting the trashed items and wanted to build the signed assembly however, of course, the strong name key file named BoxSDKKey.pfx was missing from the box-windows-sdk-v2 / Box.V2 solution. May I know why?

Regards,
Rodion.

Box-API: How can I add a strong name to a 3rd party assembly written for the .NET Portable Subset

I posted this issue also on StackOverFlow at http://stackoverflow.com/questions/17837868/box-api-how-can-i-add-a-strong-name-to-a-3rd-party-assembly-written-for-the-ne

This not necessarily an issue with the API itself unless you need a strongly named version of it, then you'll have this problem. I pasted the issue from StackOverFlow, so forgive my vagueness on calling the Box API a 3rd-party project. It is one over there but not on this sight.

Issue:
I am trying to strongly name a 3rd party API that I have the code for but it's using a 3rd party DLL/NuGet Package that is also not strongly named and I'm having a lot of trouble. I'm using the Box Windows SDK and the API was written in the .NET portable subset and supports .NET for Windows Store Apps, .NET Framework 4 and higher, SL4 and higher, and Windows Phone 7 and higher. Granted, I do not need all of these but I do need the .NET 4 and Silverlight versions. The API already works wonderfully and runs fine on its own. It would with my application also, if all my projects were unsigned but they aren't. We use strongly named assemblies for our Silverlight application in order to make use of application library caching.

Anyway, I have the source code for the API so I simply added my PFX file to the project to sign it. I then get an error that a dependency that this API is using called NitoAsnycEx.dll is not signed. I do not have the code for Nito.AsyncEx.dll but normally this isn't such a problem, more of an annoyance. So now I have an age-old problem of needing to take a 3rd party DLL of which I don't have code for and sign it with my PFX or another SNK file.

I can do either and normally I use one of the processes so wonderfully explained in this post by Ian Picknell: http://ianpicknell.blogspot.com/2009/12/adding-strong-name-to-third-party.html. So I have followed that process and the IL signing tools seem to sign the DLL just fine.

To make a long story shorter, let's use the simplest version of the signing process where I already have a simple SNK file ready to go. Basically, I do this:
1.
I can run ILDASM to get the .il file for this 3rd party EXE: ILDASM Nito.AsyncEx.dll /out:Nito.AsyncEx.il

I can then run ILASM to get the signed DLL: ILASM Nito.AsyncEx.il /dll /resource=Nito.AsyncEx.res /key=NPSAssemblyKeyNoPassword.snk

It works great and I get this result:

Method Implementations (total): 118 Resolving local member refs: 0 -> 0 defs, 0 refs, 0 unresolved Writing PE file Signing file with strong name Operation completed successfully

So now I have a signed DLL. I go back to my 3rd Party API code and remove the old reference to NitoAsyncEx.dll and put a new one to this. I try to compile and then I get an error like this:

Error 44 The base class or interface 'System.Object' in assembly 'System.Runtime, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' referenced by type 'Nito.AsyncEx.AsyncLock' could not be resolved r:\Data\GM\Source\GrantManagement\GrantManagement\3rd Party\Nito\Nito.AsyncEx.dll

I figure there is some problems using the portable .net library here but I'm not sure what it is. This same process normally works for me for Silverlight 4+ and Full .NET 4.5 framework libraries. Is there another ILASM or ILDASM set somewhere that will disassemble and reassemble the portable code correctly? Is this even possible?

I also tried to go and get the source code for the NitoAsyncEx.dll, which is open source btw, and compile it but that source code will not compile as it's missing some files. So currently I'm stuck with my integration of this API into my project and need a little assistance from any experts in the community.

Is there a way to sign this DLL correctly so we're not missing references to basic classes such as System.Object?

Is there a way to get around needing to sign this DLL at all and having it referenced from my projects?

Thanks in advance.

No progress report

You forgot to add a way to be notified of download or upload file progress.

Build fails when Box.V2 is referenced by a class library in .Net 4.0

Hi,

The following common error is raised when trying to build a class library that already has a reference to Box.V2 and during programming all works fine, until a build is performed.

The type or namespace name 'Box' could not be found (are you missing a using directive or an assembly reference?)

There are also many warnings about unresolved references by the Box.V2 like the following:

The primary reference "Box.V2" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Box.V2" or retarget your application to a framework version which contains "System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Globo.Box.Helper

Any ideas?

Thank you!

Unnecessary context switching - await's

Hi,

I noticed that there's unnecessary context switching happening in the box library code. The issue is that every async call has a "regular" await. That means that execution will continue on the captured original thread (like the UI thread).

Instead, as this is library code, every async call should have a .ConfigureAwait(false) on it. Then execution will continue on the existing thread. This will prevent unnecessary UI thread use and context switching.

You can see it as a best practice, to always use ConfigureAwait(false) in your library code:
http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html

The only place you really shouldn't use it is in your event handlers or other handlers that need to resume execution on the UI thread or context (like asp.net).

Find Folder Id

Hi,

I'm writing a server side application using the SDK. In my case if user says, upload a file at this Folder = "root\a\b". To get the folder Id ("root\a\b") I have to crawl from root ("0") . Is there any smarter way to find required folder Id?

Windows 7

Does this SDK work under Windows 7? I have the Visual Studio 2012 Express for Web (Update 3) and I cannot open the SDK project

When I call GetFolderItemsAsync it returns NullReferenceException

BoxCollection f = await client.FoldersManager.GetFolderItemsAsync(folderId, 50, 0, new List(){BoxFolder.FieldName});

This line always returns NullReferenceException. Calling it without the list and without the offset also returns an exception. Also, calling it with var instead of the explicit type returns an exception.

Return folder information when conflict exists creating a folder

When invoking client.FoldersManager.CreateAsync(...), an exception is thrown if a name conflict occurs (the folder already exists). Since information pertaining to the existing folder is returned from the API, it should be possible to expose a BoxFolder object.

Recommendation: Throw a new BoxFolderExists exception that exposes conflict information, including a BoxFolder property.

As-User

I'd like to start working on support for As-User. However, it's not clear to me where the best entry point for this is. Here are some ideas I've had:

1.
IAuthRepository could be involved, but that would likely result in breaking changes. We could:

  • Add IAuthRepository.AsUserId, which would be consumed by BoxResourceManager.AddAuthorization and added as a header to the request; or
  • Move BoxResourceManager.AddAuthorization to IAuthRepository.AddAuthorization. AuthRepository would provide the same implementation as BoxResourceManager does now. A new subclass of AuthRepository, AsUserAuthRepository, could add the additional As-User header.

2.
Another option is to add an optional asUser string to every Box*Manager method signature. BoxResourceManager.AddAuthorization would be responsible for adding the appropriate header. This feels pretty clunky to me:

public async Task<bool> DeleteAsync(string id, string etag=null, string asUser=null)

3.
Finally, we might add the same optional asUser parameter on the BoxClient and Box*Manager constructors instead of the methods. This feels a little less clunky than option (2) and wouldn't result in the breaking change of (1).

Thoughts?

Nuget

When will a Nuget package be available?

Box.V2.Exceptions.BoxSessionInvalidatedException is thrown while using an access token , refresh token created couple hours back

Hello,

I just referenced the Box SDK for my application which I am planning to run every 24 hours.
To start, I manually executed the call in browser to get the 'code'
https://app.box.com/api/oauth2/authorize?response_type=code&client_id=&state=

Using the code, I issued a call in 'PostMan' client
https://api.box.com/oauth2/token with the body as grant_type, client_id, client_secret and the code above
The response : {
"access_token": "AT", //ACCESS_TOKEN
"expires_in": 3895,
"restricted_to": [],
"refresh_token": "RT", //REFRESH_TOKEN
"token_type": "bearer"
}

===================================Code ==============================
Saving the tokens as variables, I executed the following
_boxConfig = new BoxConfig(CLIENT_ID, CLIENT_SECRET, new Uri("https://redirectUri"));
var session = new OAuthSession(ACCESS_TOKEN, REFRESH_TOKEN, 86400, "bearer");
_boxClient = new BoxClient(_boxConfig, session);
_boxClient.Auth.SessionAuthenticated += Auth_SessionAuthenticated;
_boxClient.Auth.SessionInvalidated += Auth_SessionInvalidated;

var boxItems = GetItems("0").Result;


// private methods
private async Task GetItems(BoxFolderRequest folderRequest)
{
var boxFolder = await _boxClient.FoldersManager.CreateAsync(folderRequest);
return boxFolder;
}

void Auth_SessionInvalidated(object sender, EventArgs e)
{
//do nothing
}

void Auth_SessionAuthenticated(object sender, SessionAuthenticatedEventArgs e)
{
ACCESS_TOKEN = e.Session.AccessToken;
REFRESH_TOKEN = e.Session.RefreshToken;

}

Things work fine for the first hour, but after an hour I get a Box.V2.Exceptions.BoxSessionInvalidatedException at boxClient.FoldersManager.CreateAsync which seems like the access token is expired without being able to refresh

Looking at some existing issues , I avoided use of client.Auth.RefreshAccessTokenAsync(ACCESS_TOKEN);

However, I do not seem to overcome this issue, the only way is to again get the code and fetch new tokens and things work fine which is not the ideal solution since I want the code to run as an automated process every 24 hours without popping up the browser to get the code.

In order to avoid the session invalidated exception,should I save the tokens in a database or a file and fetch them every 24 hours I run the code ? Is there any thing I am missing here
I'd appreciate any help.

Thanks

Please update the NuGet package

The NuGet package was last updated in April, and there have been a lot of important updates since then. Can we get a refresh? Thanks!

Authentication does not work with a project targeting .NET 4.5.1

Hi there,

We are currently migrating our product from VS 2010 .Net 4.0 to VS 2013 .Net 4.5.1 and can't get the Box integration working as authentication cannot be completed.

Basically under the VS 2010 we were capable of retrieving the authentication & refresh tokens and then using them to retrieve the information about users files and folders.

Now in VS 2013 & .Net 4.5.1 the authentication part could never be passed and therefore the Box integration is currently not working at all.

We are using Box.V2 SDK as a dll installed through the Nuget.
Authentication code looks as follows:
image
Please note that the breakpoint is never hit here.

While investigating the issue we integrated the Box.V2 SDK source code into our solution hoping to get better understanding of the failure but in vain.
Even though the authentication part succeeds up to the point where the OAuthSession object could be retrieved via ExchangeAuthCode (ResponseObject contains all the required data) this session object is never made it back to the original caller, i.e. the execution is not continued after this method exits:
image

We've also tried using the async/await mechanism however with no luck.

Any help is greatly appreciated.

Authentication problems / is the SDK invalidating my saved access and refresh tokens?

Hi,

I think I'm doing the authentication workflow in the right way, but too ofter I get 'refresh token has expired'. It is supposed to last for two months, so it can't be that, because the problem happens within the same day (within hours).

This is what I do: The first time (just once), I get my first access and refresh tokens pair. This is working fine.

Then, in the following hours (and luckily days and so on) I get (and save) new access and refresh tokens doing this:

var config = new BoxConfig(_settings.ClientId, _settings.ClientSecret, new Uri(RedirectUrl));
var sessionInfo = new OAuthSession(_settings.AccessToken, _settings.RefreshToken,
                                                       AccessTokenExpiresSeconds, "bearer");
_client = new BoxClient(config, sessionInfo);

var newSessionInfo = await client.Auth.RefreshAccessTokenAsync(client.Auth.Session.AccessToken);
// and I update _settings.AccessToken and _settings.RefreshToken 
// with the values found in newSessionInfo 

Why then, I'm getting the 'refresh token has expired'?
Digging into the SDK code, I see this in \Box.V2\Managers\BoxResourceManager.cs:

            switch (response.Status)
            {
                // Refresh the access token if the status is "Unauthorized" (HTTP Status Code 401: Unauthorized)
                // This will only be attempted once as refresh tokens are single use
                case ResponseStatus.Unauthorized:
                    response = await RetryExpiredTokenRequest<T>(request).ConfigureAwait(false);
                    break;

...
...
...
        protected async Task<IBoxResponse<T>> RetryExpiredTokenRequest<T>(IBoxRequest request)
            where T : class
        {
            OAuthSession newSession = await _auth.RefreshAccessTokenAsync(request.Authorization).ConfigureAwait(false);
            AddAuthorization(request, newSession.AccessToken);
            return await _service.ToResponseAsync<T>(request).ConfigureAwait(false);
        }

Therefore, could it be, you are refreshing the access and refresh tokens when you identify an expired access token?
If so, you are getting a new access and refresh tokens pair, but I never see nor get them; and my saved tokens are now invalid.
Am I right? If so, how to workaround this?
If I'm not right, why do you think I'm losing the authentication?

Thanks,
Horacio.-

UploadAsync closes the stream

Hi,

I create file, save it into MemoryStream and then pass it to SDK to Upload into box.com. This logic works for me except in one case.

When my access token get expired and I call UploadAsync, SDK automatically updates tokens and repeats the request. But first request failed due to expired tokens and stream get closed. As a result, repeated request failed too, due to closed stream.

How to deal with it?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.