30.03.2014 Views

Database.com Chatter REST API Developer's Guide - Salesforce.com

Database.com Chatter REST API Developer's Guide - Salesforce.com

Database.com Chatter REST API Developer's Guide - Salesforce.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Introducing <strong>Chatter</strong> <strong>REST</strong> <strong>API</strong><br />

Using Tokens<br />

2. After successfully logging in, the user is asked to authorize the application. Note that if the user has already authorized the<br />

application, this step is skipped.<br />

3. Once <strong>Database</strong>.<strong>com</strong> has confirmed that the client application is authorized, the end-user’s Web browser is redirected to<br />

the callback URL specified by the redirect_uri parameter, appended with the following values after the hash sign (#).<br />

This is not a query string.<br />

Parameters<br />

access_token<br />

expires_in<br />

refresh_token<br />

Description<br />

Session ID that you can use for making <strong>Chatter</strong> <strong>API</strong><br />

requests. This session ID cannot be used in the user interface.<br />

Treat this like a user's session and diligently protect it.<br />

Amount of time the access token is valid, in seconds.<br />

Token that can be used in the future to obtain new access<br />

tokens (sessions).<br />

Warning: This value is a secret. You should treat<br />

it like the user's password and use appropriate<br />

measures to protect it.<br />

The refresh token is only returned if the redirect URI is<br />

https://login.instance_name/services/oauth2/success<br />

or used with a custom protocol that is not HTTPS.<br />

The following additional parameters are returned; however, they aren't used with this flow and <strong>Chatter</strong> <strong>API</strong>:<br />

• instance_url<br />

• id<br />

• signature<br />

• issued_at<br />

4. If the client application is a Web app, the redirection Web page that it uses may include JavaScript that the client application<br />

can manipulate in order to retrieve the access and refresh tokens.<br />

Alternatively, a client application (native or web) may use the page<br />

https://login.instance_name/services/oauth2/success as their callback URL. Instead of actually loading<br />

the page on redirect, they should intercept the redirection URI and extract the parameters values. Note that the<br />

refresh_token parameter values are only provided if the redirection URI is this URI or if the redirection URI uses a<br />

custom protocol.<br />

Once the client application has retrieved the access and refresh tokens, it can use them to make requests to <strong>Chatter</strong> <strong>API</strong>.<br />

Using Tokens<br />

As part of both authentication flows, you will be working with access tokens and refresh tokens.<br />

Using Access Tokens<br />

To make a successful <strong>Chatter</strong> <strong>API</strong> request, you must include a valid access token in the request. This can be done by using<br />

the HTTP Authorization header:<br />

Authorization: OAuth <br />

21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!