• Emtecinc developer049388157163885804
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hello,

I am trying to get the access token from SF for my Mobile app.
I am not using Salesforce SDK.
I am using Phonegap as I intend to create a hybrid app.

I have written the following code :-
var loginURL = "https://login.salesforce.com/";
    var consumerKey = '3MVG9Y6d_Btp4xp4FClT2rkPVFKe3ochPsDJ.131PRuoUqzEHGysmx78HcFwCMqvWuCTX3kkcrtiULLTBz.q4';
    //this could be anything, once SF authentication is successful, SF will redirect your to this URL and
    //your inAPPBrowser will load this
    var callbackURL = 'https://login.salesforce.com/services/oauth2/success';
    var client = new forcetk.Client(consumerKey, loginURL);
    var authUrl = loginURL + 'services/oauth2/authorize?' + '&response_type=token&client_id=' + encodeURIComponent(consumerKey) + '&redirect_uri=' + encodeURIComponent(callbackURL);

    //load the SF login page in an InAppBrowser
    alert(authUrl);
    var authWindow = window.open(authUrl, "_blank",'toolbar=yes ,location=no');


This is an InAppBrowser implementation to get the access code in the URL .

However, I am unable to assign events to this child window instance.
$(authWindow).on('loadstop', function(e) { });  // This event binding is not working for me.

Please help me in order to get the access code in my parent app.

Thanks
Hello,

I am trying to get the access token from SF for my Mobile app.
I am not using Salesforce SDK.
I am using Phonegap as I intend to create a hybrid app.

I have written the following code :-
var loginURL = "https://login.salesforce.com/";
    var consumerKey = '3MVG9Y6d_Btp4xp4FClT2rkPVFKe3ochPsDJ.131PRuoUqzEHGysmx78HcFwCMqvWuCTX3kkcrtiULLTBz.q4';
    //this could be anything, once SF authentication is successful, SF will redirect your to this URL and
    //your inAPPBrowser will load this
    var callbackURL = 'https://login.salesforce.com/services/oauth2/success';
    var client = new forcetk.Client(consumerKey, loginURL);
    var authUrl = loginURL + 'services/oauth2/authorize?' + '&response_type=token&client_id=' + encodeURIComponent(consumerKey) + '&redirect_uri=' + encodeURIComponent(callbackURL);

    //load the SF login page in an InAppBrowser
    alert(authUrl);
    var authWindow = window.open(authUrl, "_blank",'toolbar=yes ,location=no');


This is an InAppBrowser implementation to get the access code in the URL .

However, I am unable to assign events to this child window instance.
$(authWindow).on('loadstop', function(e) { });  // This event binding is not working for me.

Please help me in order to get the access code in my parent app.

Thanks
Hello,

I am trying to get the access token from SF for my Mobile app.
I am not using Salesforce SDK.
I am using Phonegap as I intend to create a hybrid app.

I have written the following code :-
var loginURL = "https://login.salesforce.com/";
    var consumerKey = '3MVG9Y6d_Btp4xp4FClT2rkPVFKe3ochPsDJ.131PRuoUqzEHGysmx78HcFwCMqvWuCTX3kkcrtiULLTBz.q4';
    //this could be anything, once SF authentication is successful, SF will redirect your to this URL and
    //your inAPPBrowser will load this
    var callbackURL = 'https://login.salesforce.com/services/oauth2/success';
    var client = new forcetk.Client(consumerKey, loginURL);
    var authUrl = loginURL + 'services/oauth2/authorize?' + '&response_type=token&client_id=' + encodeURIComponent(consumerKey) + '&redirect_uri=' + encodeURIComponent(callbackURL);

    //load the SF login page in an InAppBrowser
    alert(authUrl);
    var authWindow = window.open(authUrl, "_blank",'toolbar=yes ,location=no');


This is an InAppBrowser implementation to get the access code in the URL .

However, I am unable to assign events to this child window instance.
$(authWindow).on('loadstop', function(e) { });  // This event binding is not working for me.

Please help me in order to get the access code in my parent app.

Thanks

Hello, I'm using cordova version 2.9 and forcetk.js.

 

After outh screen i want to redirect to the index.html file of my phonegap app.

I tried using file:/// link but no use.

 

can any one help me in this. How to configure the callback url in local hybrid app.

 

Thanks in advance!!

 

Hi,

 

I'm new in the plataform - I having some problems to fill in data in a ExtJs Panel Grid - When I got back the String in JSON format I define my Ext.Data.Model - I have some lookup up relations in my Query and I don't know how to define them in my Ext.Data.Model, the fields that don't have look up relationships work fine but I cant get the value from the ones that have it

 

If somebody can help me with this issue will be great!

 

Many thanks

Xisco :)

 

Here is my code:

 

<script type="text/javascript">

		Ext.ns("Ext.Classing"); //Defining a namespace is best practice in ExtJS
			
		
		Ext.onReady(function(){ //This is a execution point
			
			//This is to create InCourse panel
		    var InCoursePanel = new Ext.create('Ext.Classing.InCoursePanel', {   
		            renderTo: InCourse,
		            title : 'Students to place'
		        });
		        		    
	
	        //This method is used to call our controller method
	        Controller_ClassingSimpleGrid.getAllBookings(function(result, er){	        							
						                var res = Ext.decode(result);
						                store.loadData(res.Records);
	            					}, {escape:false});
   		});
   		
   		   		
   		//Defining a model, which is like an object
   		Ext.define('ClassingStudentsModel', {
	        extend	: 'Ext.data.Model',
	        fields	:[
			            {name: 'Id', type: 'string'},
			            {name: 'Name', type: 'string'},
			            {name: 'Gender__c', type: 'string'},
			            {name: 'Nationality__c', type: 'string'}
	    			  ]
	    });   		
   		
   		//Create a store, which is like collection of records with sorting and grouping capability
   		var store = Ext.create('Ext.data.Store', { 
	                        model 		: 'ClassingStudentsModel', //Associate your store with Model
	                        proxy 		: {
				                            type 	: 'memory',
				                            reader	: {
			                                	type : 'json',
				                          	}
	                       				  }
	                    });
   		
   		//Defining a panel in order to display our data
   		Ext.define('Ext.Classing.InCoursePanel', {
	        extend		: 'Ext.grid.Panel',
	        alias 		: 'widget.InCoursePanel',
	        name 		: 'InCoursePanel',
	        columnLines : true,
	        autoScroll	: true,
	        singleSelect: false,	        
	        border		: true,
	        height		: 300,
	        width		: 250,
	        store		: store, //Associate with our store
	        stripeRows  : true,
	        multiSelect : true,
	        columns 	: [ //Define the required columns
		                    {
		                        text 		: 'Id',
		                        dataIndex	: 'Id',
		                        flex		: 0.3
		                        //hidden      : true,
		                        //hideable    : false
		                    },
		                    {
		                        text 		: 'Name',
		                        dataIndex 	: 'Name',
		                        flex 		: 0.3
		                    },
		                    {
		                        text 		: 'Gender',
		                        dataIndex 	: 'Gender__c',
		                        flex 		: 0.3
		                    },
		                    {
		                        text 		: 'Nationality',
		                        dataIndex 	: 'Nationality__c',
		                        flex 		: 0.3
		                    }
		            	],
		});
global class Controller_SimpleGrid { 
    
@RemoteAction
    global static String getAllBookings() //Need to define as a remote action as we will be calling this through javascript
    {
        List<Booking__c> bookings = [Select Id, Enrolment__r.Account__r.Name, Enrolment__r.Account__r.Gender__c, 
                                                Enrolment__r.Account__r.Nationality__c
                                     From Booking__c
                                     Where Enrolment__r.Account__r.RecordType.Name = 'Student'];
                                     
    	system.Debug('Im here!!!!');                                     
                                     
        String JSONString = JSON.serialize(bookings);//This is how we can serailize our response into JSON format
        
        
        system.debug(JSONString);
        
        return '{\"Records\":' +JSONString+', \"error\": \"null\", \"status\":\"SUCCESS\", \"count\":\"' + bookings.size() + '\" }';
    }


}

 

 

 

 

 

  • July 16, 2012
  • Like
  • 0