Intro to the Alfresco Public API
-
Upload
jeff-potts -
Category
Technology
-
view
2.302 -
download
5
description
Transcript of Intro to the Alfresco Public API
![Page 1: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/1.jpg)
Intro to the Alfresco Public APIJeff PottsChief Community Officer
![Page 2: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/2.jpg)
Doesn’t Alfresco already have an API?Yes, but…
• Not really public (things change)• Not versioned• Not well documented• Doesn’t work for cloud
The Alfresco Public API addresses these limitations
Vision is to have a single API that works across cloud and on-premise
![Page 3: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/3.jpg)
API Launch Partners
![Page 4: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/4.jpg)
![Page 5: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/5.jpg)
![Page 6: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/6.jpg)
Folder, file, content and metadata manipulation and search
Networks, sites, people, comments, tags, activities, …
![Page 7: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/7.jpg)
Getting Started
1. Understand OAuth22. Register your app3. Grab a client-side CMIS library
• Or an SDK if coding a mobile app
4. Start coding!
![Page 8: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/8.jpg)
Step 1: Groking OAuth2
Defined in RFC-6749Secure authentication
• 3rd party apps don’t ever see the user’s password
Unambiguously identifies:• API provider (e.g. Alfresco)• Client application (e.g. your application)• End-user (e.g. an Alfresco Cloud user)
![Page 9: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/9.jpg)
OAuth2 & Alfresco
Used to secure the Alfresco APIOnly authentication mechanism
provided for APIs in Alfresco Cloud
![Page 10: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/10.jpg)
Registering an App
ApplicationDeveloper
AlfrescoDeveloper Portal
Creates developer profile
Assigns an API key and secret for that app
Signs up on developer portal
Registers an application
![Page 11: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/11.jpg)
AuthorizationApplication Alfresco End-User
Links to Alfresco authorization page, passing API key & secret
Asks the user to authorize the app
User authorizes the app to access their account
Redirects to your app’s callback URL, passing authorization code
Exchanges the authorization code for an access token
Returns access and refresh tokens
Securely persists the access and refresh token for that user
![Page 12: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/12.jpg)
Making API Calls
Calls APIs, passing the access token in the Authorization HTTP header
Identifies user from access token, executes API call
Application Alfresco
![Page 13: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/13.jpg)
Refresh Flow
Calls APIs, passing the access token in the Authorization HTTP header
Returns 401 error, indicating access token has expired
Refreshes access token, passing refresh token Returns new
access token
Application Alfresco
![Page 14: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/14.jpg)
OAuth2 library can hide detailsSpring Socialhttp://www.springsource.org/spring-
social
Google OAuth2 Clienthttps
://developers.google.com/accounts/docs/OAuth2#libraries
![Page 15: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/15.jpg)
Step 2: Register Your Apphttp://www.alfresco.com/develop
• Alfresco Cloud Account• Registered Developer Account
Add as many applications as you wantKey, secret, callback URL
![Page 16: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/16.jpg)
Step 3: CMIS Library
Apache Chemistry is the umbrella project for all CMIS related projects at the ASF• OpenCMIS (Java, client and server)• cmislib (Python, client)• phpclient (PHP, client)• DotCMIS (.NET, client)• ObjectiveCMIS (Objective-C)
Other client libraries exist
![Page 17: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/17.jpg)
REST client
http://youtu.be/5QS0CNsPJEY
![Page 18: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/18.jpg)
Create, Find, & Comment
http://youtu.be/1ZtmoPdCKJI
![Page 19: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/19.jpg)
Alfresco API URLs
Structure:• Tenant• API scope• API name• API version• Entity type
https://api.alfresco.com/
* The notion of entity types doesn’t apply to CMIS.
*
public/acme.com/ sitesalfresco/versions/1/
![Page 20: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/20.jpg)
Entity type collections
The entity type URL represents a collection of all instances of that entity• The collection may or may not be
retrievable via a GET
Each instance of an entity can be accessed via the collection URL with an Id appended.../acme.com/public/alfresco/versions/1/sites/mullet-gallery
![Page 21: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/21.jpg)
Top level entity types
sitespeopletagsnodesfavorites
![Page 22: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/22.jpg)
Nesting entity types
Entity types may also be nested
The same rule about retrieving instances by Id applies
.../acme.com/public/alfresco/versions/1/sites/mullet-gallery/members
.../acme.com/public/alfresco/versions/1/sites/mullet-gallery/members/[email protected]
![Page 23: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/23.jpg)
Create, update, & delete
Creating a new entity instance:• POST to the collection URL
Updating an entity instance:• PUT to the instance URL
Deleting an entity instance:• DELETE against the instance URL
These rules apply regardless of whether it’s a top-level or nested collection
![Page 24: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/24.jpg)
Considerations
Rate limits• 5 requests/second, 10,000 requests/day
(Dev)• 50 requests/second, 100,000 requests/day
(Prod)
No limit on # of applicationsAlfresco Cloud users own their content>= OpenCMIS 0.8.0-SNAPSHOT>= cmislib 0.5.1dev
![Page 25: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/25.jpg)
Roadmap
Merge APIs into Alfresco Enterprise v4.2New API types:
• User Provisioning (SCIM)• Workflow (Activiti)
New API versions:• CMIS v1.1• Alfresco v2 (?)
New Alfresco API entity types:• renditions• bulk-imports (?)
![Page 26: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/26.jpg)
Roadmap
Binary property supportProjection & transclusion
improvements (“SELECT”)Restriction improvements (“WHERE”)Discoverability improvements
• In support of “executable documentation”
![Page 27: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/27.jpg)
Getting HelpDocs: http://www.alfresco.com/developResources:
• Alfresco API forum• #alfresco on freenode IRC• Alfresco Technical Discussion Google Gro
up
Source Code:• Code from DevCon Session• Spring Social Alfresco Library• Peter’s Grails Example• Jeff’s Java Examples & Python Examples
![Page 28: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/28.jpg)
Read the book!
Everything you need to know about CMIS 1.0 & 1.1
Lots of Groovy and Java examples
Also covers Python, Android, & iOS
Now on MEAP!37%-off: 12cmisal
![Page 29: Intro to the Alfresco Public API](https://reader036.fdocuments.us/reader036/viewer/2022062312/555801a6d8b42a200d8b5298/html5/thumbnails/29.jpg)
The keys to one badass ECM platform are yours for the taking
http://www.alfresco.com/develophttp://www.flickr.com/photos/ph-stop/3101407532/