ARCore 클라우드 앵커 관리 API

ARCore 클라우드 앵커를 사용하여 ARCore 앱 외부의 클라우드 앵커 관리 관리 API

시작하기

작업 예

승인

서비스 계정 키 만들기 Google Cloud Platform 콘솔로 이동하여 클라우드 앵커 관리 API 호출을 승인하는 OAuth2 토큰

  1. 탐색 메뉴에서 Google Cloud Platform 콘솔에서 APIs & Services > Credentials입니다.

  2. 원하는 프로젝트를 선택한 후 Create Credentials 아이콘을 클릭합니다. Service account

  3. Service account details 아래에 새 계정의 이름을 입력합니다. Create를 클릭합니다.

  4. Service account permissions 페이지에서 Select a role(으)로 이동합니다. 선택합니다. Service Accounts 선택 > Service Account Token Creator, Continue를 클릭합니다.

  5. Grant users access to this service account 페이지에서 Done를 클릭합니다. 그러면 APIs & Services(으)로 돌아갑니다. > Credentials

  6. Credentials 페이지에서 Service Accounts 섹션까지 아래로 스크롤합니다. 방금 만든 계정의 이름을 클릭합니다.

  7. Service account details 페이지에서 Keys 섹션까지 아래로 스크롤합니다. 그런 다음 Add Key > Create new key입니다.

  8. 키 유형으로 JSON를 선택하고 Create를 클릭합니다. 이렇게 하면 JSON이 다운로드됩니다. 개인 키가 포함된 파일을 머신에 업로드합니다. 다운로드한 JSON 저장 키 파일을 안전한 위치에 보관해야 합니다.

OAuth2 토큰 생성

arcore.management은 Cloud Anchors Management API의 OAuth 범위입니다. 작성자: 기본적으로 oauth2l은 토큰 캐시에서 작동합니다. fetch 명령어는 토큰입니다. oauth2l을 사용하여 OAuth2 생성 승인용 토큰:

oauth2l fetch --json creds.json arcore.management

새 토큰을 생성하려면 --cache="" 옵션을 fetch에 추가합니다. 명령어와 함께 사용하면 됩니다

oauth2l fetch --cache="" --json creds.json arcore.management

또는 oauth2l reset를 호출하고 fetch 명령어를 다시 호출합니다.

oauth2l reset
oauth2l fetch --json creds.json arcore.management

모든 클라우드 앵커 나열

클라우드 앵커의 첫 페이지를 가져옵니다. 원하는 경우 expire_time 기준으로 정렬됩니다. create_time 또는 last_localize_time입니다.

요청:

export BEARER_TOKEN=`(oauth2l fetch --json creds.json arcore.management)`
curl -H "Authorization: Bearer $BEARER_TOKEN" \
"https://arcore.googleapis.com/v1beta2/management/anchors?page_size=50&order_by=last_localize_time%20desc"

대답:

{
  "anchors": [
    {
      "name": "anchors/ua-a1cc84e4f11b1287d289646811bf54d1",
      "createTime": "...",
      "expireTime": "...",
      "lastLocalizeTime": "...",
      "maximumExpireTime": "..."
    },
   …
    {
      "name": "anchors/ua-41a3d0233471917875159f6f3c25ea0e",
      "createTime": "...",
      "expireTime": "...",
      "lastLocalizeTime": "...",
      "maximumExpireTime": "..."
    }
  ],
  nextPageToken: "some-long-string"
}

응답이 nextPageToken로 돌아오면 목록. 다음 요청에서 next_page_token 쿼리 매개변수를 사용하여 확인할 수 있습니다.

요청:

curl -H "Authorization: Bearer $BEARER_TOKEN" \
"https://arcore.googleapis.com/v1beta2/management/anchors?page_size=50&order_by=last_localize_time%20desc&next_page_token=your-next-page-token-here"

next_page_token를 사용할 때는 page_sizeorder_by가 일관되어야 합니다. 전체 요청 수에 따라 달라집니다 page_size의 기본값은 1000이고 order_by의 기본값은 다음과 같습니다. expire_time_desc입니다.

클라우드 앵커의 TTL(수명)을 허용되는 최대 시간으로 업데이트

단일 클라우드 앵커를 요청하여 lastLocalizeTimemaximumExpireTime

요청:

export BEARER_TOKEN=`(oauth2l fetch --json creds.json arcore.management)`
curl -H "Authorization: Bearer $BEARER_TOKEN" \
"https://arcore.googleapis.com/v1beta2/management/anchors/your-anchor-id-here"

대답:

{
  "name": "anchors/ua-f21be53fd8ea57f0169c69fbf827f6b7",
  "createTime": "2020-06-29T21:00:00Z",
  "expireTime": "2020-08-28T22:00:00Z",
  "lastLocalizeTime": "2020-06-29T21:00:00Z",
  "maximumExpireTime": "2021-06-29T21:00:00Z"
}

앵커가 있으면 expireTimemaximumExpireTime로 업데이트합니다.

요청:

curl -H "Authorization: Bearer $BEARER_TOKEN" -H "Content-Type: application/json" -X "PATCH" \
"https://arcore.googleapis.com/v1beta2/management/anchors/your-anchor-id-here?updateMask=expire_time" \
-d '{ expireTime: "2021-06-29T21:00:00Z" }'

대답:

{
  "name": "anchors/ua-f21be53fd8ea57f0169c69fbf827f6b7",
  "createTime": "2020-06-29T21:00:00Z",
  "expireTime": "2021-06-29T21:00:00Z",
  "lastLocalizeTime": "2020-06-29T21:00:00Z",
  "maximumExpireTime": "2021-06-29T21:00:00Z"
}

클라우드 앵커 삭제

단일 클라우드 앵커를 삭제합니다.

export BEARER_TOKEN=`(oauth2l fetch --json creds.json arcore.management)`
curl -H "Authorization: Bearer $BEARER_TOKEN" -X "DELETE" \
"https://arcore.googleapis.com/v1beta2/management/anchors/your-anchor-id-here"

클라우드 앵커 배치를 삭제합니다.

export BEARER_TOKEN=`(oauth2l fetch --json creds.json arcore.management)`
curl -H "Authorization: Bearer $BEARER_TOKEN" -H "Content-Type: application/json" -X "POST" \
"https://arcore.googleapis.com/v1beta2/management/anchors:batchDelete" \
-d '{ names: [ "anchors/your-anchor-id-here", "anchors/your-anchor-id-here" ]}'