def test_access_token_expires(self):
        an_minute_before_from_now = datetime.datetime.utcnow(
        ) - datetime.timedelta(minutes=1)
        access_token = AccessToken(self.foo_token,
                                   expires_at=an_minute_before_from_now)

        self.assertTrue(access_token.is_expired())
    def test_app_secret_proof(self):
        access_token = AccessToken(self.foo_token)
        app_secret_proof = access_token.app_secret_proof('shhhhh!is.my.secret')

        self.assertEqual(
            '796ba0d8a6b339e476a7b166a9e8ac0a395f7de736dc37de5f2f4397f5854eb8',
            app_secret_proof)
Esempio n. 3
0
 def access_token(self):
     # type: () -> AccessToken
     from facebook_sdk.authentication import AccessToken
     return AccessToken(access_token='{app_id}|{secret}'.format(
         app_id=self.app_id,
         secret=self.secret,
     ), )
Esempio n. 4
0
    def access_token(self):
        """

        :return:
        """
        from facebook_sdk.authentication import AccessToken
        return AccessToken(access_token='{id}|{secret}'.format(
            id=self.id, secret=self.secret))
Esempio n. 5
0
 def set_default_access_token(self, access_token):
     if isinstance(access_token, str):
         self.default_access_token = AccessToken(access_token=access_token)
     elif isinstance(access_token, AccessToken):
         self.default_access_token = access_token
     else:
         raise ValueError(
             'The default access token must be of type "str" or AccessToken'
         )
Esempio n. 6
0
    def test_access_token_do_not_expires(self):
        app_access_token = AccessToken(self.app_token)

        self.assertFalse(app_access_token.is_expired())
Esempio n. 7
0
    def test_long_lived_access_token(self):
        a_week_from_now = datetime.datetime.utcnow() + datetime.timedelta(weeks=1)
        access_token = AccessToken(self.foo_token, expires_at=a_week_from_now)

        self.assertTrue(access_token.is_long_lived())
Esempio n. 8
0
    def test_short_lived_access_token(self):
        an_hour_from_now = datetime.datetime.utcnow() + datetime.timedelta(hours=1)
        access_token = AccessToken(self.foo_token, expires_at=an_hour_from_now)

        self.assertFalse(access_token.is_long_lived())
Esempio n. 9
0
    def test_is_valid_access_token(self):
        access_token = AccessToken(self.foo_token)
        app_access_token = AccessToken(self.app_token)

        self.assertFalse(access_token.is_app_access_token())
        self.assertTrue(app_access_token.is_app_access_token())
Esempio n. 10
0
    def test_initialize(self):
        access_token = AccessToken(self.foo_token)

        self.assertEqual(access_token.access_token, self.foo_token)