1

I have followed the instructions to create a react_native sample app on this page

Everything works, but what I am trying to understand is where does the

oauth.authenticate()

Store the tokens, and how does it then pass the token to the forceClient()

2

I can understand that this can be a bit confusing as it's not really documented very well. The key concept here is that forcClient is an instance of react.force.net.js

var forceClient = require('./react.force.net.js');

When a user authenticates using oauth.authenticate - under the hood, it returns a data dictionary comprising of

 * Returns a dictionary with:
 *     accessToken
 *     refreshToken
 *     clientId
 *     userId
 *     orgId
 *     loginUrl
 *     instanceUrl
 *     userAgent
 */

The forceClient reads this data dictionary and it has all the session information as well as target org/ user details available to fire subsequent SOQL operations using the query() method

As an example

var soql = 'SELECT Id, Name FROM Account LIMIT 10';
        forceClient.query(soql,
                          function(response) {
                              var users = response.records;
                              var data = [];
                              var count = 0;
                              for (var i in users) {
                                  data.push(users[i]["Name"]);
                                  count++;
                          }

I hope that answers your question. I'd recommend watching this video to understand this in further detail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.