Completed
Pull Request — master (#349)
by Tomaz
02:59
created

YammerAction.authenticate()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 3
rs 10
1
try:
2
    import yampy
3
except ImportError:
4
    message = ('Missing "yampy", please install it using pip:\n'
5
               'pip install yampy')
6
    raise ImportError(message)
7
8
from st2actions.runners.pythonrunner import Action
9
10
__all__ = [
11
    'YammerAction',
12
]
13
14
15
class YammerAction(Action):
16
    def __init__(self, config):
17
        super(YammerAction, self).__init__(config)
18
        self.client_id = self.config['client_id']
19
        self.client_secret = self.config['client_secret']
20
        self.expected_redirect = self.config['expected_redirect']
21
        self.authenticator = yampy.Authenticator(
22
            client_id=self.client_id,
23
            client_secret=self.client_secret)
24
        self.access_code = self.config['access_code']
25
        self.user_info = None
26
        self.network_info = None
27
28
    def authenticate(self):
29
        access_token = self.authenticator.fetch_access_token(self.access_code)
30
        return yampy.Yammer(access_token=access_token)
31