1. #1
    Sencha User
    Join Date
    Jun 2012
    Location
    Geel, Antwerp, Belgium
    Posts
    5
    Vote Rating
    0
    NielsVerhesen is on a distinguished road

      0  

    Default 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

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Answers
    124
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Hi!

    you may try the following:-


    you may try to use setInterval for your needs:-
    Code:
    setInterval(function() {
         var accessToken= '12345678998754321' //sample token
         graph.facebook.com/me?access_token=' + accessToken;
    }, 15000); //specific time (in ms) after function is called again
    The setInterval() method will continue calling the function until clearInterval() is called

    OR, you may use delayedTask, if you need it only once
    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);
    For more info, check this:-
    http://docs.sencha.com/touch/2-0/#!/...il.DelayedTask
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Location
    Geel, Antwerp, Belgium
    Posts
    5
    Vote Rating
    0
    NielsVerhesen is on a distinguished road

      0  

    Default


    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

  4. #4
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Answers
    124
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    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.

  5. #5
    Sencha User
    Join Date
    Jun 2012
    Location
    Geel, Antwerp, Belgium
    Posts
    5
    Vote Rating
    0
    NielsVerhesen is on a distinguished road

      0  

    Default


    Quote Originally Posted by sword-it View Post
    have u check link at the bottom of my post?

    it basically creates a setTimeOut for your function, it will called after a specified duration (in ms).
    you will get more what it do on the link..
    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
        }
    });

  6. #6
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Answers
    124
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default



    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?
    ok, now i understood your needs!
    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.

Thread Participants: 1

Tags for this Thread