Showing posts with label sharepoint porting. Show all posts
Showing posts with label sharepoint porting. Show all posts

16 October, 2013

How To Control App Token Lifetimes in SharePoint 2013?

SharePoint has emerged to be one of the most beneficial web application development platforms these days. The newer versions of this platform have turned out to be of immense use for the business enterprises as, they assist in the successful accomplishment of several tasks and necessitate much less time and efforts. Now, developers are trying out more innovative ways of exploiting SharePoint so as to derive the maximum advantages out of this already useful platform. Controlling the app token lifetimes in SP 2013 is one area of concern that is emphasized upon to a significant extent.

SharePoint development companies
The first question that arises in this regard is where one can control the app token lifetimes. However, when considered on a broader platform, it will be seen that the place of control is actually not so significant and that a highly advanced app like TokenHelper can be of substantial help. There are around one or two JWT tokens that are created if one goes by the IssueToken method. It is usually one when the app only token is being used and two tokens for the application and the current user. However, in both the events, the JsonWebSecurityToken is created and the parameter that is used to create the same determines as to how long it is valid.

It is for the app token that the TokenHelper makes use of a constant, which is known as TokenLifeTimeMinutes. By default, this constant has a value of 1,000,000, which leaves no scope of worrying except in cases where one wants to limit it. Now, for the user token, the constant is hard- coded by default for making use of a lifetime of 10 minutes. The values can be found as well as changed into whatever you want just with a little drilling into the IssueToken method.

With a deeper look into the code, it can be seen that the TokenHelper incorporates a delegate that is invoked in what is known as the GetClientContextWithAccessToken method. This method plays the important role in adding a bearer token to any particular request that comes into the SharePoint from the particular app of the user.

Now, if the user sets a breakpoint on that specific line of code and eventually step through the request from the app, none of the token 'setup' functions creating the ClientContext will be resulting in an HTTP call. At this point, the ExecuteQuery method has to be called on the ClientContext object. The request goes over the wire, the delegate fires and finally, the token is added to the request. While one can cache the access token obtained in the high trust app, there may not always be a justified reason behind doing so.

On the other hand, caching the app tokens is beneficial only at the time of using the relatively low trust apps. When such is the case, one has to save one or more trips to ACS for the purpose of accessing token at the time of caching them. In events where there are multiple users or several requests, the process helps. The only thing that one needs to be aware of in this regard is the right ways of caching the tokens for the low trust apps.

This is just a brief overview of the overall process of controlling application lifetimes in SharePoint 2013 along with a discussion about the use and benefits of the high trust as well as the low trust apps. However, it is a task that needs to be taken up by only the experts and pros in the field, who are aware of the processes and can therefore, adept in handling the same to produce faster results in less time.

You can hire developers from top SharePoint development companies in India who can help you build products within allocated budgets and time schedules.

We provide SharePoint CMS customization services. If you would like to know more about the expertise of our SharePoint developers, please get in touch with us at Mindfire Solutions.

23 September, 2013

Steps to create a SharePoint 2013 App with Ruby on Rails

The SharePoint model is quite new to everybody and the recent launch of the 2013 version had made it even more ambiguous to developers around the world. Now, when it comes to creating an application pertaining to the software with Ruby on Rails, most developers seem to have a tough time in embracing the appropriate approach. Well, here is a guide for all Rails developers looking forward to creating an app successfully on the particular framework. However, please note that this particular guide should never be used as the best practice of Ruby on Rails development.

SharePoint portal development
Well, before beginning the process, you must register a new application in Office 365. Ensure that a Site Collection has been created by making use of the Developer Site Template. This can be done from the Office 365 admin screens. Following the creation of the same, browse site collection and register the SharePoint application with Office 365 as well as Azure Access Control Services (ACS). For any sort of development purpose, the registration of the new app can be easily done through appregnew.aspx page present within Office 365. Since there is no such link available for the actual page, you need browse the URL directly.

Always remember that since the registration of the application is done through appregnew.aspx, the secret of the particular app will only be known by the ACS and you. Therefore, the series of characters that will be generated will be specifically used for decoding information coming from ACS/SharePoint. Always make sure to take note of the id of the app, as you will not be having any access of the same again.

Since the application will be only used for testing and development purposes, registering it through appregnew.aspx comes across as a wise choice. If there arises a need of making the app thoroughly and widely available or list in the official store of SharePoint, then an account must be registered at the Seller Dashboard.

1. Visual Studio

The next step of work rests with Visual Studio where an application package must be created, which would eventually be uploaded to SharePoint. To make this happen, you need to follow the following steps:
  • Open Visual Studio (through 'Run as Administrator') for creating a new project. Go for project creation using the template ‘App for SharePoint 2013’. You will find this under the SharePoint /Office project node.
  • Following this, you will be asked about the type of SharePoint app that you would like to create. Always remember to offer your app a similar name to that you have given in the appregnew.aspx and submit the URL of the Developer site collection. Ensure choosing an application type of Provider – hosted as the hosting model.
  • In the last screen, leave the top option by selecting ‘Use a client secret’. Once, you click on the button OK, you will get to see the creation of 2 projects in Solution Explorer.
  • It is to be noted that the first project usually implies to the SharePoint App that generates the application package. This particular app will be uploaded.
  • The following step requires you to double click AppManifest.xml that consists of all the details related to the app. Upon opening the Manifest Designer, you need to remember to insert some specific values.
Always remember that the application needs to take permissions for being able to read and write data to the SharePoint site where the application is installed. This can be easily done through the permission tab. All you need to do is request just the permission that is actually needed. Always note that the more permission the app would request, the more it will run the risk of not being installed as users will be concerned about the security risk. Always remember to save and then close the AppManifest designer.

2. Ruby on Rails and Apple MacOS

To be able to work with SharePoint 2013, there stands a requirement of installing Ruby Gems to make things easier. Here is a look at the needs:
  • jwt – this helps in decoding the JSON web token that emerges from the application software
  • rest-client – this enables placing rest requests
  • nokogiri – a library that helps querying XML that is usually returned from the SharePoint
the next step of action lies in creating a new application based on Ruby on Rails in your preferred code folder. All you need to do is type into Terminal. Rails is now ready for getting a MVC web application.

Open the gemfile and under the gem stated as ‘jquery-rails’, integrate the gems that were downloaded as pre-reqs.
  • gem ‘jwt’
  • gem ‘rest-client’
  • gem ‘nokogiri’
This particular step is quite similar to the task of adding new reference in Visual Studio assembly.

3. Https Configuration

You must have noticed that while registering the application in appregnew.aspx, a Redirect URL is set that is https://localhost:3001. The app will be making use of the OAuth for being able to authorize the user and the application. Remember, that the for ensuring OAuth specification, both ends of communication must be https. After all, you would definitely not want any poor interception of unencrypted tokens to be transmitted over the Internet and have an access to the Office 365 or SharePoint site. Rails usually make use of WEBric, which is developed in web server. This is quite similar to the IISExpress of the Visual Studio.

To get the SharePoint 2013 mobile development right, you would have to follow the steps above. Then hopefully, you will be able to successfully create a SharePoint app with Ruby on Rails.

We provide SharePoint portal development services. If you would like to know more about the expertise of our expert SharePoint developers, please get in touch with us at Mindfire Solutions.