Newer Version Available
Step Three: Connect to Chatter REST API Using OAuth
Complete Step Two: Set Up Authorization and create a connected app before starting this task.
| Connected App Application Label | Value in Example |
|---|---|
| Consumer Key | client_id |
| Consumer Secret | client_secret |
To make a request to Salesforce, substitute values from your organization into these examples:
-
Generate the access token. This cURL command generates an access token:
1curl -v https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=3MVG9PhR6g6B7ps4xDycwGrI4PvjVZvK9" -d "client_secret=8870355475032095511" -d "username=admin@seattleapps.com" -d "password=test1234mB1riuD3n"The response includes the server instance and the access token:1{ 2"access_token":"00Dd0000000d2Iy!AQgAQLwpOxN4DhZO2qB8PCbD8VU1T35znzeDeCm....", 3"instance_url":"https://instance_name.my.salesforce.com", 4"id":"https://login.salesforce.com/id/00Dd000000XXXXXXX/005d000000XXXXX", 5"token_type":"Bearer", 6"issued_at":"1486507938095", 7"signature":"uEY/R99P/uqgq0GYNQKcvKc9LqICOMf91NvwI2my4eI=" 8} -
To request a Chatter REST API resource, use the returned instance_url as the server instance. Pass the returned access_token as a Bearer token in the Authorization request
header.
1curl -X GET https://instance_name/services/data/v41.0/chatter/users/me 2 -H 'Authorization: Bearer 00DD0000000FJ6T!AQkAQPde_DMF2vGzddfZmBRS95Goj 3 DbtArKkgukAgZP0OVFYY5KkAqhLw9ejeKIlpJ3FgwGAWeRlBiWRt8mfXEuAZGbZNosk'
| Property | Value |
|---|---|
| client_id | 3MVG9PhR6g6B7ps4xDycwGrI4PvjVZvK9 |
| client_secret | 8870355475032095511 |
| grant_type | password The value of grant_type depends on the OAuth authentication flow you are using. Append the user’s security token to their password. A security token is an automatically generated key from Salesforce. For example, if a user's password is mypassword, and their security token is XXXXXXXXXX, then the value provided for this parameter must be mypasswordXXXXXXXXXX. |
| username | admin@seattleapps.com |
| password | test1234mB1riuD3n |