Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Hands-on with OAuth, Facebook and the Platform


Published on

OAuth 2.0 is now the default mechanism for authorizing access to Web services APIs, supported by providers across the Internet. In this workshop, aimed at developers and architects, we will look at the OAuth 2.0 protocol, build a portal on that acquires customers via Facebook, logs them in via OAuth 2.0, and use the Facebook Graph API to create a social application, combining business data in with users' social graphs in Facebook. Bring a laptop with a web browser and a text editor - no development environment needed - we'll be coding in the cloud, baby!

Presented at Cloud Identity Summit 2012.

Published in: Technology, Business
  • Be the first to comment

Hands-on with OAuth, Facebook and the Platform

  1. 1. Hands-on withOAuth, Facebook and PlatformPat PattersonPrincipal Developer @metadaddy
  2. 2. Safe HarborSafe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation maycontain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertaintiesmaterialize or if any of the assumptions proves incorrect, the results of, inc. could differmaterially from the results expressed or implied by the forward-looking statements we make. All statementsother than statements of historical fact could be deemed forward-looking, including any projections ofsubscriber growth, earnings, revenues, or other financial items and any statements regarding strategies orplans of management for future operations, statements of belief, any statements concerning new, planned, orupgraded services or technology developments and customer contracts or use of our services.The risks and uncertainties referred to above include – but are not limited to – risks associated with developingand delivering new functionality for our service, our new business model, our past operating losses, possiblefluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach ofour security measures, risks associated with possible mergers and acquisitions, the immature market in whichwe operate, our relatively limited operating history, our ability to expand, retain, and motivate our employeesand manage our growth, new releases of our service and successful customer deployment, our limited historyreselling products, and utilization and selling to larger enterprise customers. Furtherinformation on potential factors that could affect the financial results of, inc. is included in ourannual report on Form 10-K for the most recent fiscal year ended January 31, 2012. This document andothers are available on the SEC Filings section of the Investor Information section of our Web site.Any unreleased services or features referenced in this or other press releases or public statements are notcurrently available and may not be delivered on time or at all. Customers who purchase our services shouldmake the purchase decisions based upon features that are currently available., inc. assumesno obligation and does not intend to update these forward-looking statements.
  3. 3. Agenda 1:05 Introductions 1:15 The OAuth 2.0 Authorization Framework 1:25 Social Sign-On with Authentication Providers 1:45 Exercise 1: Configure an Auth Provider 2:15Break 2:30 The Facebook Graph API 2:45 The Toolkit for Facebook 3:00 Exercise 2: Create a Social Application 3:30 Roadmap 3:45 Q&A
  4. 4. Materials
  5. 5. OAuth 2.0
  6. 6. OAuth 2.0 Authorization for RESTful APIs Evolution of Google AuthSub, Yahoo BBAuth, AOL OpenAuth etc „Valet key‟ for the web Emphasis on simplicity, ease of implementation
  7. 7. OAuth Roles
  8. 8. OAuth 2.0 ProtocolAuthorization Resource Server Browser Client App Server GET /something 302 Found Location: ype=code&client_id=…&redirect GET /?response_type=... _uri=…&scope=… Authenticate 302 Found Location:… GET /… POST /token code=…&grant_type=authorization_code&client_id=…&client_secre t=…&redirect_uri=… 200 OK { “access_token”: “00D5…”} GET /data Authorization: Bearer 00D5… 200 OK 200 OK Data Some Content
  9. 9. Identity Service OAuth response contains „id‟ element:{ "access_token": "00D5...”,"id": " 50000001fg5OAAQ", "instance_url": "", "issued_at": "1308806720993", "signature": "GhBp..."} We can access this URL (with the OAuth token) to obtain information on the user Same pattern as OpenID Connect
  10. 10. Social Sign-On
  11. 11. CRM processes have historically been disconnected
  12. 12. The Social Enterprisecommunicates in new ways…
  13. 13. …but how do social customers and partners directly engage with your products and services?
  14. 14. IntroducingSocial Sign-On
  15. 15. Social Sign-On – Automatically create and update users and contacts – Single Sign-On makes it easy and keeps them coming back – Deliver applications and services to deepen your relationship – Active engagement automatically updates your customer data
  16. 16. So what’s under the covers? The Auth Providers Framework – Pre-integrated Single Sign-On from branded Identity Services – Automatically create and update Contacts and Users – Full control over data modeling with Apex Registration Handlers – Works for both internal and external users Out of the box support – Facebook: B2C – Salesforce: B2B – JanRain: Breadth & Depth support for a wide catalog of Identity Providers
  17. 17. When to use Auth Providers Business to Consumer – Use Facebook or JanRain for more options Business to Partner – Use Login with Salesforce for collaborating with Partners or Customers that have existing Salesforce deployments – Use SAML for point to point federations Business to Employee – SAML is still the preferred option ( see roadmap ) – SAML provides static
  18. 18. Exercise 1
  19. 19. Exercise 1: Configure an Auth Provider Create a Developer Edition environment Create a Customer Portal Create a Site, and link it to the portal Create a Facebook App Create an Authentication Provider Create a login page for the portal Login to the portal from Facebook
  20. 20. The Facebook Graph API
  21. 21. The Facebook Graph API
  22. 22. Accessing Social Graph Objects Every social graph object has a unique ID – For example, Facebook Platform has ID 19292868552 – GET
  23. 23. Relationships – Edges on the Graph Friends, feed (wall), likes, photos, videos, etc Graph API terminology: connections – For example, my friends – Special ID - me – GET
  24. 24. Graph API Authorization OAuth 2.0 – Obtain access token representing user‟s permission to access their social graph – Supply it with Graph API calls as a query parameter • Access to specific types of graph objects is controlled by permissions – user_likes, friends_photos, publish_stream etc – Requested via OAuth 2.0 scope – Balance app functionality against intrusiveness
  25. 25. Searching Search via GET post&access_token=AAA
  26. 26. Publishing HTTP POST to a connection URL – Access token is required! – curl -F access_token=... -F message=Hello world! – Response: {"id":"667905711_10151088147280712"}
  27. 27. Graph API Explorer
  28. 28. The Force.comToolkit for Facebook
  29. 29. Sidebar: Writing Apps for Platform-as-a-Service – Apps run on the Salesforce infrastructure Model-View-Controller architecture – Model = – View = Visualforce – Controller = Apex Workbook is a great place to start –
  30. 30. Toolkit for Facebook Apex binding for the Facebook Graph API Map<String,String>params = new Map<string,string>{fields => id,name, limit => 10}; FacebookUsersfriendsList = new FacebookUsers(access_token, me/friends, params); for (FacebookUseru : { System.debug(; } Graph API objects modeled as Apex classes – FacebookUser, FacebookPhotoetc Open source, but unsupported
  31. 31. Exercise 2
  32. 32. Exercise 2: Create a Social Application Add a Visualforce page to the portal Retrieve the user‟s friends list Expand the requested scope Retrieve the user‟s photos Think – what could I do next?
  33. 33. Roadmap
  34. 34. Roadmap for Auth Providers StartURLs and Custom Scopes – Pilot during Summer 12 timeframe Communities,, and Orgs – Authentication for Collaboration, Marketing, and multi-org single sign-on Make it great for employees – Tie into My Domains so it works just like SAML
  35. 35. Resources Workbook Digging Deeper into OAuth 2.0 on Social Single Sign-On – Authentication Providers in Spring ‟12 Janrain Social Sign-On Spring „12 Release Notes Toolkit for Facebook
  36. 36. Q&A