authentication - Authenticate External App to Salesforce instance -


i building mobile application need fetch data salesforce instance. have no problem soql grab appropriate data. however, not want user of mobile app have log in token, need use access data.

is possible authenticate app via appid , client secret in application allow appropriate use/access of apis? similar authenticating app parse or firebase instance without requiring authenticated user.

thanks!

this example in nodejs/express , in example accounts:

var express = require('express'); var router = express.router(); var nforce = require('nforce'); /* home page. */ router.get('/', function(req, res, next) {  var accounts =[]; // create connection salesforce connected app var org = nforce.createconnection({ clientid: process.env.client_id, clientsecret: process.env.client_secret, redirecturi: process.env.callback_url, mode: 'single' });   // authenticate , return oauth token  org.authenticate({  username: process.env.username,  password: process.env.password+process.env.security_token  }, function(err, resp){   if (!err) {    console.log('successfully logged in! cached token: ' +    org.oauth.access_token);   // execute query   org.query({ query: 'select id, name account' }, function(err, resp){     if(!err && resp.records) {       // output account names       (i=0; i<resp.records.length;i++) {         //console.log(resp.records[i].get('name'));         accounts.push(resp.records[i].get('name'));       }        res.render('index', { title:'accounts',accounts:accounts });     }   }); }  if (err) console.log(err);  });    //console.log(accounts);   });   module.exports = router; 

you need api crendentials authenticate , not matter language using concept same.

username : salesforce user name

password: salesforce password

security_token: user security token , if don't have can go settings -personal -reset security token , salesforce send token email.

the other parameters parameters app , have register app security tokens.

for create connected apd go : setup -build-create apps in section of connected apps create new one. connected api generate consumer key , consumer secret.

client_id: consumer key

client_secret:is consumer secret

callback_url: callback url in example : http://localhost:3000


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -