Hands-on with OAuth, Facebook and the Force.com Platform

5,746 views
5,560 views

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 Force.com 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 Force.com 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
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,746
On SlideShare
0
From Embeds
0
Number of Embeds
270
Actions
Shares
0
Downloads
92
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • This is a fairly typical model. Sales rep starts their day with working on some opportunities
  • They find and pull up a contact
  • They interact with them,collect some data, log calls and activities and put it in your database
  • And you end up fillingyour CRM database with all of these Identities….which is good, but the customer isn’t directly engaged
  • Increasingly your customers and partners are out on Social Networks interacting with each other, discussing your products and brand
  • We’re giving you the tools like Social Accounts and Contacts to provides your sales users with social sales intelligence that they can use to better meet existing and potential customers’ needs.
  • And tools like radian6 to monitor and engage with customers
  • Hands-on with OAuth, Facebook and the Force.com Platform

    1. 1. Hands-on withOAuth, Facebook and theForce.com PlatformPat PattersonPrincipal Developer Evangelistsalesforce.comppatterson@salesforce.com @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 salesforce.com, 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 non-salesforce.com products, and utilization and selling to larger enterprise customers. Furtherinformation on potential factors that could affect the financial results of salesforce.com, 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. Salesforce.com, 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 Force.com Toolkit for Facebook 3:00 Exercise 2: Create a Social Application 3:30 Roadmap 3:45 Q&A
    4. 4. Materials http://lanyrd.com/sryxw
    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: https://login.ex.com/?response_t ype=code&client_id=…&redirect GET /?response_type=... _uri=…&scope=… Authenticate 302 Found Location: https://app.cl.com?code=… GET /app.cl.com?code=… 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. Force.com Identity Service OAuth response contains „id‟ element:{ "access_token": "00D5...”,"id": "https://login.salesforce.com/id/00D50000000IZ3ZEAW/005 50000001fg5OAAQ", "instance_url": "https://na1.salesforce.com", "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 Force.com Developer Edition environment Create a Customer Portal Create a Force.com 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 https://developers.facebook.com/docs/reference/api/
    22. 22. Accessing Social Graph Objects Every social graph object has a unique ID – https://graph.facebook.com/ID For example, Facebook Platform has ID 19292868552 – GET https://graph.facebook.com/19292868552
    23. 23. Relationships – Edges on the Graph Friends, feed (wall), likes, photos, videos, etc Graph API terminology: connections – https://graph.facebook.com/ID/CONNECTION_TYPE For example, my friends – Special ID - me – GET https://graph.facebook.com/me/friends
    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 • https://graph.facebook.com/ID?access_token=TOKENVALUE 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 https://graph.facebook.com/search GET https://graph.facebook.com/search?q=force.com&type= 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! https://graph.facebook.com/me/feed – Response: {"id":"667905711_10151088147280712"}
    27. 27. Graph API Explorer https://developers.facebook.com/tools/explorer
    28. 28. The Force.comToolkit for Facebook
    29. 29. Sidebar: Writing Apps for Force.com Platform-as-a-Service – Apps run on the Salesforce infrastructure Model-View-Controller architecture – Model = database.com – View = Visualforce – Controller = Apex Force.com Workbook is a great place to start – http://developer.force.com/workbook
    30. 30. Force.com 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 : friendsList.data) { System.debug(u.name); } 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, Site.com, 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 Force.com Workbook http://developer.force.com/workbook Digging Deeper into OAuth 2.0 on Force.com http://bit.ly/oauth2-force Social Single Sign-On – Authentication Providers in Spring ‟12 http://bit.ly/sso-authproviders Janrain Social Sign-On http://janrain.com/salesforce Spring „12 Release Notes http://developer.force.com/releases/release/Spring12 Force.com Toolkit for Facebook http://wiki.developerforce.com/page/Facebook_Toolkit21
    36. 36. Q&A

    ×