HACK TODO: can we get this token from the cookie?
776604
function scrapeToken()  {
        get({
            url : server + "/user/"+username,
            callback : function(error, body) {
                if( error ) return callback(error);
                jsdom.env(body,
                        ["http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"],
                        function(errors, window) {
                    var apikey = window.$("dd.value code");
                    if( apikey.length > 0 ) {
                        key = apikey.html();
                        callback();
                    } else {
                        callback({error:true,message:"login failed"});
                    }
                }
                );
            }
        })
    }
333906
def parse_session_cookie(cookie_to_cook):
    
    #print("cookie_to_cook: %s"%str(cookie_to_cook))
    session_value = None
    tokens = cookie_to_cook.split(";")
    for tok in tokens:
        if 'remi_session=' in tok:
            #print("found session id: %s"%str(tok))
            try:
                session_value = int(tok.replace('remi_session=', ''))
            except:
                pass
    return session_value
792979
def request_token(self):
        
        logging.debug("Getting request token from %s:%d",
                      self.server, self.port)
        token, secret = self._token("/oauth/requestToken")
        return "{}/oauth/authorize?oauth_token={}".format(self.host, token), \
            token, secret
532082
def _oauth_tokengetter(token=None):
    
    token = session.get("oauth")
    log.debug("Token Get: {0}".format(token))
    return token
1290936
def parse_cookies(self, req, name, field):
        """"""
        return core.get_value(req.cookies, name, field)
848395
function getCSRFToken() {
		if (typeof document === "undefined") return null;
		var cookies = document.cookie.split(";");//$NON-NLS-0$

		var i,n,v;
		for(i = 0; i<cookies.length; i++) {
			n = cookies[i].substr(0, cookies[i].indexOf("=")).trim();//$NON-NLS-0$
			v = cookies[i].substr(cookies[i].indexOf("=") + 1).trim();//$NON-NLS-0$

			if(n.endsWith(XSRF_TOKEN)) {
				return v;
			}
		}
	}
142852
def _polling_cookie(self):
        
        parsed_url = urlparse(self._response.request.url)
        host = parsed_url.hostname.strip('.')
        if host == 'localhost':
            return {'cookie': self._response.headers.get('set-cookie', '')}
        return {}
72125
function logon() {
    var dfrd = Q.defer();
    var token = cache.get('token');

    function extractToken(xml) {
      var r = _parse(xml, dfrd);
      if (r) {
        return r.response.token[0];
      }
    }

    if (token) {
      dfrd.resolve({
        token: token,
        cached: true
      });
    }

    request(format(URLs.logon, PROTOCOL, conf.host, conf.username,
        conf.password),
      function(err, res, body) {
        var newToken;
        if (err) {
          dfrd.reject(err);
        } else {
          newToken = extractToken(body);
          if (!newToken) {
            dfrd.reject(MODULE_ERRORS.unknown);
          } else {
            cache.put('token', newToken);
            dfrd.resolve({
              token: newToken,
              cached: false
            });
          }
        }
      });
    return dfrd.promise;
  }
423263
def info(self, token):
        
        verifier = JWT(key_jar=self.key_jar, allowed_sign_algs=[self.alg])
        _payload = verifier.unpack(token)
        if is_expired(_payload['exp']):
            raise ToOld('Token has expired')
        return _payload['sid'], _payload['ttype']
413780
function getCookie(cname) {
            var name = cname + "=";
            var ca = doc.cookie.split(';'),
                i = 0,
                l = ca.length;
            for (; i < l; i++) {
                var c = ca[i];
                while (c.charAt(0) == ' ') {
                    c = c.substring(1);
                }if (c.indexOf(name) != -1) return unescape(c.substring(name.length, c.length));
            }
            return "";
        }
940359
function getRequestCookies(req) {
  if (req.headers.cookie != null) {
    try {
      return parseCookie(req.headers.cookie);
    } catch (e) {
      this.log(req.urlData.pathname, "Error parsing cookie header: " + e.toString());
      return {};
    }
  } else {
    return {};
  }
}
117653
def parse_cookies(self, req, name, field):
        """"""
        return core.get_value(req.COOKIES, name, field)
51938
def token(ctx, opts, login, password):
    """"""
    click.echo(
        "Retrieving API token for %(login)s ... "
        % {"login": click.style(login, bold=True)},
        nl=False,
    )

    context_msg = "Failed to retrieve the API token!"
    with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
        with maybe_spinner(opts):
            api_key = get_user_token(login=login, password=password)

    click.secho("OK", fg="green")

    click.echo(
        "Your API key/token is: %(token)s"
        % {"token": click.style(api_key, fg="magenta")}
    )

    create, has_errors = create_config_files(ctx, opts, api_key=api_key)

    if has_errors:
        click.echo()
        click.secho("Oops, please fix the errors and try again!", fg="red")
        return

    if opts.api_key != api_key:
        click.echo()
        if opts.api_key:
            click.secho(
                "Note: The above API key doesn't match what you have in "
                "your default credentials config file.",
                fg="yellow",
            )
        elif not create:
            click.secho(
                "Note: Don't forget to put your API key in a config file, "
                "export it on the environment, or set it via -k.",
                fg="yellow",
            )
            click.secho(
                "If you need more help please see the documentation: "
                "%(website)s" % {"website": click.style(get_help_website(), bold=True)}
            )
        click.echo()

    click.secho("You're ready to rock, let's start automating!", fg="green")
603498
def get_bdstoken(cookie):
    '''
    '''
    url = const.PAN_REFERER
    req = net.urlopen(url, headers={'Cookie': cookie.header_output()})
    if req:
        return parse_bdstoken(req.data.decode())
    else:
        return None
828115
public String getTokenValue(String tokenName) {
		Cookie ck = tokenValues.get(tokenName);
		if (ck != null) {
			return ck.getValue();
		}
		return null;
	}
520762
function getcookie(req, name, secrets) {
  var header = req.headers.cookie;
  var raw;
  var val;

  // read from cookie header
  if (header) {
    var cookies = cookie.parse(header);

    raw = cookies[name];

    if (raw) {
      if (raw.substr(0, 2) === 's:') {
        val = unsigncookie(raw.slice(2), secrets);

        if (val === false) {
          debug('cookie signature invalid');
          val = undefined;
        }
      } else {
        debug('cookie unsigned')
      }
    }
  }

  // back-compat read from cookieParser() signedCookies data
  if (!val && req.signedCookies) {
    val = req.signedCookies[name];
  }

  // back-compat read from cookieParser() cookies data
  if (!val && req.cookies) {
    raw = req.cookies[name];

    if (raw) {
      if (raw.substr(0, 2) === 's:') {
        val = unsigncookie(raw.slice(2), secrets);

        if (val === false) {
          debug('cookie signature invalid');
          val = undefined;
        }
      } else {
        debug('cookie unsigned')
      }
    }
  }

  return val;
}
775483
function getUserForToken(decodedToken) {
        var userId = decodedToken._id;
        var authToken = decodedToken.authToken;
        var cacheKey = userId + authToken;
        var conditions = {
            caller: userService.admin,
            where: { _id: userId, authToken: authToken, status: 'created' },
            findOne: true
        };
        var cachedUser;

        // if no user id or authToken, then no user
        if (!userId || !authToken) { return null; }

        // try to get user from cache, then DB
        return userCacheService.get({ key: cacheKey })
            .then(function (user) {
                cachedUser = user;
                return user ? user : userService.find(conditions);
            })
            .then(function (user) {

                // if user found in database, but not in cache, save in cache
                if (user && !cachedUser) {
                    userCacheService.set({ key: cacheKey, value: user });
                }

                // return the user
                return user;
            });
    }