Configure the Global OAuth Settings to include a device code, and enable the OAuth 2.0
device flow. OAuth 2.0 device flows integrate apps that run on devices with limited input or
display capabilities, such as smart TVs, appliances, and other internet of things (IoT) devices.
Command-line apps can also use this flow. Users can connect these apps to Salesforce by accessing
a browser on a device with more advanced input capabilities, such as a desktop or mobile
device.
Required Editions
- Open the external client app global OAuth settings file.
- Set the isDeviceFlowEnabled field to true, and save the file.
- Use a cURL request to get a device code.
curl -X POST <org URL>/services/oauth2/token -d 'response_type=device_code&client_id=3MVG9AOp4kbriZOLTqSCO6pgdL3iEegchEYYc74zsqfvJuyTC1xy4IQiPAv_mU0rtwXKJt73Seybuvhj8Jrws&redirect_uri=https://www.example.com' | json_pp
This call returns a verification URL, a user code, and a device code.
- Visit the verification URL on a computer or mobile device, and enter the user code.
- Use the device code to complete the flow using a cURL request.
curl -X POST <org URL>/services/oauth2/token -d 'grant_type=device&client_id=3MVG9AOp4kbriZOLTqSCO6pgdL3iEegchEYYc74zsqfvJuyTC1xy4IQiPAv_mU0rtwXKJt73Seybuvhj8Jrws&code=<device code>' | json_pp
The response includes a bearer token. Use this token to authorize in other flows.