Any examples on how to use OAuth from within a Sencha Touch application?
Any examples on how to use OAuth from within a Sencha Touch application?
Tried searching and nothing really usable. Does the service you are using support JSONP? That is really the biggest thing I could see to get around. Other than that is just creating some ajax calls (and maybe encryption) to do what they want.
Mitchell Simoens @LikelyMitch
Check out my GitHub:
https://github.com/mitchellsimoens
Posts are my own, not any current, past or future employer's.
I too would really love something using oauth, or a childbrowser of some sort.
I'm using salesforce and no, they don't support jsonp for authentication, I've been trying to get the ChildBrowser.js to work with xcode, and sencha but no go...
We're currently using jsOAuth with Sencha but it's for OAuth 1.0 and requires cross-domain XMLHttpRequests, ie: only works in a phonegap or sencha native wrapper app.
https://github.com/bytespider/jsOAuth
unfortunately I do need oauth 2, but I'll def look into it anyway.
jensenaxel : The only way I can think of connecting to salesforce.com is using ' Force.com JS REST Toolkit' however that requires a local hosting of a Proxy.php to route the REST API calls to SF so as to overcome 'Cross Domain' policy issue
I have posted another thread for the same which you could keep a tab on.
http://www.sencha.com/forum/showthre...ght=connecting
I got the bytespider jsOAuth working like a charm, but when it comes to the store-proxy-integration I don't know where ot start.
Maybe you have a hint.
When I call oauth.get('...') evereything works fine, but how do I tell my store to use the oauth as proxy instead of it's usual ajax behavior. Or am I missing something?
Thx,
Axel
Solved it.
I modified jsOAuth to my own needs (https://github.com/axeff/jsOAuth, hopefully it will be in the next version) and added a "public" function getHeaderString() which returns the needed header-information.
This needs to be called before every request, because the timestamp, nonce and signature needs to be re-done everytime.
so this is how it looks now:
Would probably be a good idea to overwrite the load function to automatically call setProxy() before loading.Code:var store = Ext.StoreManager.lookup("..."); var url = store.getProxy().getUrl(); store.setProxy({headers: {'Authorization': 'OAuth ' + oauth.getHeaderString(url)}}) store.load();