LinkedIn

Thursday, October 20, 2016

Rest, OAuth and OData in SharePoint

Representational State Transfer Application Program Interface (REST API)  is an architectural style (Communication Protocol) which help in communicate over HTTP, using  verbs such as GET, POST, PUT and DELETE.
In Simple words, REST is an communication protocol which uses HTTP for communication between Clients(Browsers) & Servers.

Developers can now interact remotely with SharePoint data by using any technology that supports REST web requests. This means that developers can perform Create, Read, Update, and Delete (CRUD) operations from their SharePoint Add-ins, solutions, and client applications, using REST web technologies and standard Open Data Protocol (OData) syntax.

OData is a Standard protocol or a set of rules for creating RESTful calls. You can use OData system query options to control the result.
OAuth is not the protocol for authenticating users to access SharePoint. It would still be done by Claims Authentication. The OAuth comes into picture when we want to authenticate and authorize SharePoint 2013 Apps. OAuth is the internet protocol for creating and managing app identity. It is also a cross-platform mechanism for authentication and authorizing apps. The OAuth is also the emerging internet standard which is used by Facebook, Twitter and Google.
OData is a Standard protocol or a set of rules for creating RESTful calls. You can use OData system query options to control the result. OData defines an abstract data model and a protocol (HTTP) that let any client access information exposed by any data source.
OData's answer is the Entity Data Model. In many ways a modern take on the familiar entity-relationship model, the EDM models data as entities and associations among those entities. This general approach lets the EDM -- and thus OData -- work with pretty much any kind of data.
The client.svc web service in SharePoint handles this HTTP request and returns the response in JSON format. A client application handling this request can parse the response.

OData which was set to become THE reference API for access to data for applications based on HTTP requests (for communication with the server)
 OData uses the REST concepts for operations ie using HTTP verbs:
·         GET => Reading
·         POST => Insert
·         PATCH => Modification
·         DELETE => Delete
An OData query is composed of 3 major parts:
The service URL
The URL of the desired resource
Possible settings (filter, sort ...)
·      Now about SharePoint including the 2010 version was introduced via OData client.svc service to access the data. SharePoint 2013 extends the functionalities of client.svc especially now implements OData in accordance with the standards of this protocol. SharePoint 2013 also offers a client-side API (MSOC) that can be used in .NET or JavaScript which is partly based on OData. client.svc still exists but an alias created (_api) to simplify calls to SharePoint to retrieve data (eg http: // server / sites / TeamSite / _api / lists )
OAuth is not the protocol for authenticating users to access SharePoint. It would still be done by Claims Authentication. The OAuth comes into picture when we want to authenticate and authorize SharePoint 2013 Apps. OAuth is the internet protocol for creating and managing app identity. It is also a cross-platform mechanism for authentication and authorizing apps. The OAuth is also the emerging internet standard which is used by Facebook, Twitter and Google.
Step 1 –> The user accesses the SharePoint 2013 portal and SharePoint 2013 authenticates the user using Claims Authentication
Step 2 –>  SharePoint 2013 requests for the Context Token for the user, from Windows Azure ACS (Access Control Services)
Step 3 –> ACS returns Context Token
Step 4 –> SharePoint 2013 passes the Context Token to the user
Step 5 –> User accesses App using Context Token
Step 6 –> Client App pulls Refresh Token from the Context Token and requests ACS for oAuthToken
Step 7 –> ACS server returns OAuth token to the client app
Step 8 –> Client App makes CSOM/REST calls to SharePoint site by passing OAuth Token
Step 9 –> SharePoint 2013 returns site content to App based on the App Permission Manifests
Step 10 –> Client App returns the App Content to the user.


No comments:

Post a Comment