MCPcopy Create free account
hub / github.com/CesiumGS/cesium-native / me

Method me

CesiumIonClient/src/Connection.cpp:233–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231} // namespace
232
233CesiumAsync::Future<Response<Profile>> Connection::me() const {
234 // /v1/me endpoint doesn't exist when ion is running in single user mode
235 if (this->_appData.authenticationMode == AuthenticationMode::SingleUser) {
236 Profile profile;
237 profile.id = 0;
238 profile.username = "ion-user";
239 profile.storage = ProfileStorage{
240 0,
241 std::numeric_limits<int64_t>::max(),
242 std::numeric_limits<int64_t>::max()};
243 profile.email = "none@example.com";
244 profile.emailVerified = true;
245 profile.scopes = {
246 "assets:read",
247 "assets:list",
248 "assets:write",
249 "profile:read",
250 "tokens:read",
251 "tokens:write"};
252 profile.avatar = "https://www.gravatar.com/avatar/"
253 "4f14cc6c584f41d89ef1d34c8986ebfb.jpg?d=mp";
254 return this->_asyncSystem.createResolvedFuture<Response<Profile>>(
255 Response<Profile>{
256 std::move(profile),
257 200,
258 std::string(),
259 std::string()});
260 }
261
262 const std::string url = CesiumUtility::Uri::resolve(this->_apiUrl, "v1/me");
263
264 return this->ensureValidToken().thenImmediately(
265 [pAssetAccessor = this->_pAssetAccessor,
266 asyncSystem = this->_asyncSystem,
267 url](Result<std::string>&& result) {
268 if (!result.value) {
269 return asyncSystem.createResolvedFuture(
270 createNoValidTokenResponse<Profile>(std::move(result)));
271 }
272
273 return pAssetAccessor
274 ->get(
275 asyncSystem,
276 url,
277 {{"Accept", "application/json"},
278 {"Authorization", *result.value}})
279 .thenImmediately(
280 [](std::shared_ptr<CesiumAsync::IAssetRequest>&& pRequest) {
281 const IAssetResponse* pResponse = pRequest->response();
282 if (!pResponse) {
283 return createEmptyResponse<Profile>();
284 }
285
286 if (pResponse->statusCode() < 200 ||
287 pResponse->statusCode() >= 300) {
288 return createErrorResponse<Profile>(pResponse);
289 }
290

Callers 1

TestConnection.cppFile · 0.45

Calls 9

ensureValidTokenMethod · 0.95
parseJsonObjectFunction · 0.85
getInt64OrDefaultFunction · 0.85
getStringOrDefaultFunction · 0.85
getBoolOrDefaultFunction · 0.85
thenImmediatelyMethod · 0.45
getMethod · 0.45
responseMethod · 0.45
statusCodeMethod · 0.45

Tested by

no test coverage detected