def _refresh_token_flow(self):
     """Given a refresh token, obtain a new access token."""
     url = "%s%s/oauth2/token" % (self.scheme, self.host)
     options = {
         "grant_type": "refresh_token",
         "client_id": self.options.get("client_id"),
         "client_secret": self.options.get("client_secret"),
         "refresh_token": self.options.get("refresh_token"),
     }
     verify_ssl = self.options.get("verify_ssl", True)
     self.token = wrapped_resource(make_request("post", url, options, verify_ssl))
     self.access_token = self.token.access_token
 def _credentials_flow(self):
     """Given a username and password, obtain an access token."""
     url = "%s%s/oauth2/token" % (self.scheme, self.host)
     options = {
         "client_id": self.options.get("client_id"),
         "client_secret": self.options.get("client_secret"),
         "username": self.options.get("username"),
         "password": self.options.get("password"),
         "grant_type": "password",
     }
     verify_ssl = self.options.get("verify_ssl", True)
     self.token = wrapped_resource(make_request("post", url, options, verify_ssl))
     self.access_token = self.token.access_token
    def _request(self, method, resource, **kwargs):
        """Given an HTTP method, a resource name and kwargs, construct a
        request and return the response.
        """
        url = self._resolve_resource_name(resource)

        if hasattr(self, "access_token"):
            kwargs.update(dict(oauth_token=self.access_token))
        if hasattr(self, "client_id"):
            kwargs.update(dict(client_id=self.client_id))

        verify_ssl = self.options.get("verify_ssl", True)
        return wrapped_resource(make_request(method, url, kwargs, verify_ssl))
 def exchange_token(self, code):
     """Given the value of the code parameter, request an access token."""
     url = "%s%s/oauth2/token" % (self.scheme, self.host)
     options = {
         "grant_type": "authorization_code",
         "redirect_uri": self.options.get("redirect_uri"),
         "client_id": self.options.get("client_id"),
         "client_secret": self.options.get("client_secret"),
         "code": code,
     }
     verify_ssl = self.options.get("verify_ssl", True)
     self.token = wrapped_resource(make_request("post", url, options, verify_ssl))
     self.access_token = self.token.access_token
     return self.token
示例#5
0
 def _refresh_token_flow(self):
     """Given a refresh token, obtain a new access token."""
     url = '%s%s/oauth2/token' % (self.scheme, self.host)
     options = {
         'grant_type': 'refresh_token',
         'client_id': self.options.get('client_id'),
         'client_secret': self.options.get('client_secret'),
         'refresh_token': self.options.get('refresh_token')
     }
     options.update({
         'verify_ssl': self.options.get('verify_ssl', True),
         'proxies': self.options.get('proxies', None)
     })
     self.token = wrapped_resource(make_request('post', url, options))
     self.access_token = self.token.access_token
示例#6
0
    def _request(self, method, resource, **kwargs):
        """Given an HTTP method, a resource name and kwargs, construct a
        request and return the response.
        """
        url = self._resolve_resource_name(resource)

        if hasattr(self, 'access_token'):
            kwargs.update(dict(oauth_token=self.access_token))
        if hasattr(self, 'client_id'):
            kwargs.update(dict(client_id=self.client_id))

        kwargs.update({
            'verify_ssl': self.options.get('verify_ssl', True),
            'proxies': self.options.get('proxies', None)
        })
        return wrapped_resource(make_request(method, url, kwargs))
示例#7
0
 def _refresh_token_flow(self):
     """Given a refresh token, obtain a new access token."""
     url = '%s%s/oauth2/token' % (self.scheme, self.host)
     options = {
         'grant_type': 'refresh_token',
         'client_id': self.options.get('client_id'),
         'client_secret': self.options.get('client_secret'),
         'refresh_token': self.options.get('refresh_token')
     }
     options.update({
         'verify_ssl': self.options.get('verify_ssl', True),
         'proxies': self.options.get('proxies', None)
     })
     self.token = wrapped_resource(
         make_request('post', url, options))
     self.access_token = self.token.access_token
示例#8
0
    def _request(self, method, resource, **kwargs):
        """Given an HTTP method, a resource name and kwargs, construct a
        request and return the response.
        """
        url = self._resolve_resource_name(resource)

        if hasattr(self, 'access_token'):
            kwargs.update(dict(oauth_token=self.access_token))
        if hasattr(self, 'client_id'):
            kwargs.update(dict(client_id=self.client_id))

        kwargs.update({
            'verify_ssl': self.options.get('verify_ssl', True),
            'proxies': self.options.get('proxies', None)
        })
        return wrapped_resource(make_request(method, url, kwargs))
示例#9
0
 def _credentials_flow(self):
     """Given a username and password, obtain an access token."""
     url = '%s%s/oauth2/token' % (self.scheme, self.host)
     options = {
         'client_id': self.options.get('client_id'),
         'client_secret': self.options.get('client_secret'),
         'username': self.options.get('username'),
         'password': self.options.get('password'),
         'scope': getattr(self, 'scope', ''),
         'grant_type': 'password'
     }
     options.update({
         'verify_ssl': self.options.get('verify_ssl', True),
         'proxies': self.options.get('proxies', None)
     })
     self.token = wrapped_resource(make_request('post', url, options))
     self.access_token = self.token.access_token
示例#10
0
 def exchange_token(self, code):
     """Given the value of the code parameter, request an access token."""
     url = '%s%s/oauth2/token' % (self.scheme, self.host)
     options = {
         'grant_type': 'authorization_code',
         'redirect_uri': self.options.get('redirect_uri'),
         'client_id': self.options.get('client_id'),
         'client_secret': self.options.get('client_secret'),
         'code': code,
     }
     options.update({
         'verify_ssl': self.options.get('verify_ssl', True),
         'proxies': self.options.get('proxies', None)
     })
     self.token = wrapped_resource(make_request('post', url, options))
     self.access_token = self.token.access_token
     return self.token
示例#11
0
 def exchange_token(self, code):
     """Given the value of the code parameter, request an access token."""
     url = '%s%s/oauth2/token' % (self.scheme, self.host)
     options = {
         'grant_type': 'authorization_code',
         'redirect_uri': self._redirect_uri(),
         'client_id': self.options.get('client_id'),
         'client_secret': self.options.get('client_secret'),
         'code': code,
     }
     options.update({
         'verify_ssl': self.options.get('verify_ssl', True),
         'proxies': self.options.get('proxies', None)
     })
     self.token = wrapped_resource(
         make_request('post', url, options))
     self.access_token = self.token.access_token
     return self.token
示例#12
0
 def _credentials_flow(self):
     """Given a username and password, obtain an access token."""
     url = '%s%s/oauth2/token' % (self.scheme, self.host)
     options = {
         'client_id': self.options.get('client_id'),
         'client_secret': self.options.get('client_secret'),
         'username': self.options.get('username'),
         'password': self.options.get('password'),
         'scope': getattr(self, 'scope', ''),
         'grant_type': 'password'
     }
     options.update({
         'verify_ssl': self.options.get('verify_ssl', True),
         'proxies': self.options.get('proxies', None)
     })
     self.token = wrapped_resource(
         make_request('post', url, options))
     self.access_token = self.token.access_token