-
19 Jul 2012 1:21 AM #1
Unanswered: Facebook Graph API renew access token automatically
Unanswered: Facebook Graph API renew access token automatically
Hello,
In my app I want to show a list with all status messages from one Facebook-profile. The user has not have to login to Facebook while using my app.
It works fine if I manually set an access token (generated at the Graph API Explorer) in my proxy-url in my store, but only for a couple of hours. After a couple of hours my list is empty.
I discovered that these access tokens expire within a certain time. Is there a way to generate a new access token every time the old one expires, or every time someone opens my application?
A million thanks in advance!
Niels
-
19 Jul 2012 1:38 AM #2Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 76
- Answers
- 124
Hi!
you may try the following:-
you may try to use setInterval for your needs:-
The setInterval() method will continue calling the function until clearInterval() is calledCode:setInterval(function() { var accessToken= '12345678998754321' //sample token graph.facebook.com/me?access_token=' + accessToken; }, 15000); //specific time (in ms) after function is called again
OR, you may use delayedTask, if you need it only once
For more info, check this:-Code:var FbToken= Ext.create('Ext.util.DelayedTask', function() { var accessToken= '12345678998754321' //sample token graph.facebook.com/me?access_token=' + accessToken; }); // Wait 500s before calling our function. FbToken.delay(500000);
http://docs.sencha.com/touch/2-0/#!/...il.DelayedTasksword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
19 Jul 2012 2:23 AM #3
Do I have to place this piece of code inside a function in my proxy-url of my store?
And what exactly does this code do?
Thanks
-
19 Jul 2012 2:24 AM #4Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 76
- Answers
- 124
have u check link at the bottom of my post?
it basically creates a setInterval or setTimeOut for your function, it will called after a specified duration (in ms).
you will get more what it do on the link..sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
19 Jul 2012 2:37 AM #5
Yes, but I don't know where to put your code. Here's my store code how it looks now:
Code:Ext.define('BShore.store.StoreFB', { xtype: 'StoreFB', extend: 'Ext.data.Store', config: { model: 'BShore.model.ModelFB', proxy:{ type:'jsonp', url:'https://graph.facebook.com/VBZR.SAR/statuses?limit=10&access_token=AAACEdEose0cBADQGq6F0cZB0KfgzjZAfwdPvY2cwdozCUxOKT6M1ZBtpn8jruuR7XkO6UmYWBR8zPlkBZC8pcv3H31bTgavpRGZAqGtNwsgZDZD', reader:{ type:'json', rootProperty: 'data' } }, autoLoad : true } });
-
19 Jul 2012 3:12 AM #6Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 76
- Answers
- 124
ok, now i understood your needs!
The user has not have to login to Facebook while using my app.
Is there a way to generate a new access token every time the old one expires, or every time someone opens my application?
Sorry! for generating a new access token , you need to get user login to Facebook while using your application.
When user logged in, you may obtain an access token from Facebook, it will be valid immediately and usable. After a certain period has elapsed, the access token is considered to have expired and the user will need to be authenticated again in order for your app to obtain a fresh access token.sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.


Reply With Quote