You need to sign in to do that
Don't have an account?

PhoneGap application callback/redirect url issue
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!!
I am assuming that you are launching the SalesForceLogin page via Phonegap's InAppBrowser and once you authenticate and allow permission you want to get back to the home page. If this is your use case, here is a code that you could us for reference
You will never leave your index.html page for authentication but you would simply open a browser that loads the login page.
//on Dom Ready
$(function(){
//Listen for device ready
document.addEventListener("deviceready",onDeviceReady);
//on Device Ready
function OnDeviceReady(){
var loginURL = "https://login.salesforce.com/";
var consumerKey = '<YOUR-KEY>';
//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
var authWindow = window.open(data.authUrl, "_blank", 'location=no,toolbar=no,clearsessioncache=yes');
//register a loadstop event hander on the InAppBrowser, this gets called when ever your
//inAppBrowser changes url
authWindow.addEventListener('loadstop', function(e) {
var loc = e.url;
//when url is changed check if the url contains your specific callbackURL
if (loc.search(data.callbackURL) >= 0) {
//at this point close your inapp browser
//you will land on the index page within your application.
authWindow.close();
//your code after successful authentication
}
});
}
});
Hope this helps
-
Nikhil
Also may i know, how to authendicate in username-password flow without asking for username and password.
I am trying to do the same thing as explained above.
I am able to authenticate using InAppBrowser. However I am not able to bind the loadstart and loadstop event of InappBrowser to the child window.
I want to some how get the access token from URL of child window into the parent app.
Can u pls help me
Maybe you already know the answer because it been about four months ago, but anyway i will anwser for others ones that have the same problem.
To solve your problem, try to add the InAppBrowser plugin to your project.
I was having this same issue, I added the plugin and then i could bind the event.
Hope this will help!
Were you able to solve this issue?
Thanks,
Ambily
Your help here will be very much appreciated and congrats for doing a wonderful job here.
Cheers
Samuel.