SharePoint auto-Hosted App : Licensing and fake license for dev

1

Mai 22, 2014 par jvanderoost

Hi all,

Today I decided to invite a friend to write this article with me. His name is Taylan Bagcigil and he worked with me on a SharePoint App for Microsoft. Here’s the link of his LinkedIn profile : Taylan and mine.

The idea of ​​this article is to have a vision of what the licensing Office Store, how it works? What is architecture? How to simulate a license when I’m developing?

These are questions that will be raised during your development.

The Licensing Framework :

The licensing framework for apps for Office and SharePoint gives you a way to include code in your apps to verify and enforce their legal use. You can restrict access to your apps to only those users who have a valid license, or specify which features are available, how the app behaves, or other logic, based on the properties of that license. If you plan to sell your app, you should build in logic that uses the licensing framework to determine whether a user has a valid license for the app, and give access to its features based on the license’s properties.

The app license framework itself does not enforce app licenses. It’s a structure in which you can add code to your apps to retrieve and then act on license information.

The app license framework applies only to apps acquired directly from the Office Store or apps from the Office Store that are made available in an app catalog hosted on SharePoint 2013.

The different types of license:

FREE : No change in behavior, app can function the same. However, if you reply on the license token to determine user identity of your free app, you might want to provide a notice to the user asking them to sign in in to Office with a Microsoft account to get the full benefits of your app.

TRIAL : Provide the same trial app experience when the user anonymous. If you rely on the licence token to determine user identity of your trial app. You might want to provide a notice user asking them to sign in in to Office with a Microsoft Account to get the full benefits of your app.

PAID : If your app only supports paid licences, you should present the user with information about your app, rather than a functional app, along with a hyperlink to your app’s Office Store listing page. This way users will be aware of your app and encouraged to purchase it.

How do app licenses work ?

A small diagram is worth a thousand words 🙂 :

Workflow1. The user launches the app from within SharePoint.
2. This launches the app code in the cloud (We are in Auto-Hosted app and then in the cloud :-)).
3. When the app needs to verify a user’s app license, it uses server side code to query SharePoint, via the client object model for the app license token.
4. It then passes that token to the Office Store verification service.
5. The verification service returns whether the license token is valid, and if it’s also returns the license properties.
6. The app can then take action, based on the validity of the license and its properties.

(Source : MSDN).

STEP 1 : Import a test License

This sample is an auto hosted app that you can deploy on your office 365 Developer Site. Simply deploy the .app package (using the app catalog or directly on your dev site by adding it to yours apps in testing section). This sample allow you to import and manage license.

You can download this sample License App : here

License

STEP 2 : Manage APP License

We now need to assign users to test our licenses. To do this, you must go to the director of SharePoint, and go to the menu like this:

ManageNow, simply click on the app you just add :

ChooseYou go to the next screen, allowing you to associate users with licenses « test » :
AddUser

STEP 3 : Add code to retrieve and validate a license in your « real » app

To begin you must add a Service reference (https://verificationservice.officeapps.live.com/ova/verificationagent.svc), then you get this:

LicenseVerif
Before going further into the code, you must add the class SPAppLicenseHelper.cs, You can find this class in the solution which can be downloaded here above or directly on MSDN.

I want to show you first, the code to check if a license has been assigned to a user without considering if it is: trial, free, paid :

CaptureIt remains to verify that the apps is still valid despite the license to do so we will check the information received by our service as follows:

Capture

Handling test tokens also forms an important part of enforcing licenses. You can use this to perform special validation or to handle test tokens appropriately by giving a test experience. The verification service response lets you enable this using the IsTest property.

What does a license token look like ?

<r v= »1″><t aid= »WA103403563″ pid= »fdd5f373-c524-4123-b716-b583c532abe1″ cid= »8491CA951DB109E0″ ts= »1″ et= »Paid » ad= »2014-04-06T09:07:40Z » sd= »2014-04-06″ te= »2014-04-06T07:20:45Z » /><d>jFHyWsqnl4JFuFHBwX01ZiLGezvk7bt4JHk35wu7wtg=</d></r>

Conclusion :

SharePoint 2013 has a lot of exciting new features and it will be interesting to see how to SharePoint Product Team continues to build and package it! The Apps is one of new great feature and licensing really intrusting set up!

Enjoy !

Une réflexion sur “SharePoint auto-Hosted App : Licensing and fake license for dev

  1. ajrames dit :

    Hello Jonathan.
    I’m reading your blog now for a long time. Specially the entrys about auto-hosted apps were interesting, because I (and my workmates) was developing them.
    We were really shocked about the Information that the autohosted apps will not be offered anymore by Microsoft, as we read here:
    http://blogs.office.com/2014/05/16/update-on-autohosted-apps-preview-program/
    So I’m wondering about this entry, because I think you now about that issue.
    Now we have to change from autohosted to provider hosted apps. Fortunately we can use our code, even we have some problems in the first step to make it run.
    What are your opinion about the autohosted app issue?

Laisser un commentaire

Entrez votre adresse mail pour suivre ce blog et être notifié par email des nouvelles publications.

Rejoignez les 133 autres abonnés