MCPcopy Create free account
hub / github.com/comaps/comaps / FetchSessionId

Method FetchSessionId

libs/editor/osm_auth.cpp:144–160  ·  view source on GitHub ↗

Opens a login page and extract a cookie and a secret token.

Source from the content-addressed store, hash-verified

142
143// Opens a login page and extract a cookie and a secret token.
144OsmOAuth::SessionID OsmOAuth::FetchSessionId(string const & subUrl, string const & cookies) const
145{
146 string const url = m_baseUrl + subUrl + (cookies.empty() ? "?cookie_test=true" : "");
147 HttpClient request(url);
148 request.SetCookies(cookies);
149 if (!request.RunHttpRequest())
150 MYTHROW(NetworkError, ("FetchSessionId Network error while connecting to", url));
151 if (request.WasRedirected())
152 MYTHROW(UnexpectedRedirect, ("FetchSessionId Unexpected redirected to", request.UrlReceived(), "from", url));
153 if (request.ErrorCode() != HTTP::OK)
154 MYTHROW(FetchSessionIdError, (DebugPrint(request)));
155
156 SessionID sid = {request.CombinedCookies(), FindAuthenticityToken("/login", request.ServerResponse())};
157 if (sid.m_cookies.empty() || sid.m_authenticityToken.empty())
158 MYTHROW(FetchSessionIdError, ("Cookies and/or token are empty for request", DebugPrint(request)));
159 return sid;
160}
161
162void OsmOAuth::LogoutUser(SessionID const & sid) const
163{

Callers

nothing calls this directly

Calls 7

WasRedirectedMethod · 0.80
ErrorCodeMethod · 0.80
CombinedCookiesMethod · 0.80
DebugPrintFunction · 0.70
FindAuthenticityTokenFunction · 0.70
emptyMethod · 0.45
RunHttpRequestMethod · 0.45

Tested by

no test coverage detected