def get_access_token(self, code):

    if not (isinstance(code, str) or isinstance(code, unicode)):
      code = code['code']

    body = urllib.urlencode({
      'grant_type': 'authorization_code',
      'client_id': self.client_id,
      'client_secret': self.client_secret,
      'code': code,
      'redirect_uri': self.redirect_uri,
      'scope': self.scope
      })
    headers = {
      'user-agent': self.user_agent,
    }
    http_client = atom.http_core.HttpClient()
    http_request = atom.http_core.HttpRequest(uri=self.token_uri, method='POST',
                                              headers=headers)
    http_request.add_body_part(data=body,
                               mime_type='application/x-www-form-urlencoded')
    response = http_client.request(http_request)
    body = response.read()
    if response.status == 200:
      self._extract_tokens(body)
      return self
    else:
      error_msg = 'Invalid response %s.' % response.status
      try:
        d = simplejson.loads(body)
        if 'error' in d:
          error_msg = d['error']
      except:
        pass
      raise OAuth2AccessTokenError(error_msg)
Exhanges a code for an access token.
dataset/ETHPy150Open acil-bwh/SlicerCIP/Scripted/attic/PicasaSnap/gdata/gauth.py/OAuth2Token.get_access_token