공지사항:
2025년 4월 15일 전에 Earth Engine 사용을 위해 등록된 모든 비상업용 프로젝트는 Earth Engine 액세스를 유지하기 위해
비상업용 자격 요건을 인증해야 합니다.
ee.data.authenticateViaOauth
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
자바스크립트용 Google API 클라이언트 라이브러리를 통해 EE API 호출의 클라이언트 측 인증을 구성합니다. 페이지에 아직 로드되지 않은 경우 라이브러리가 자동으로 로드됩니다. 사용자가 이전에 EE 데이터에 대한 액세스 권한을 부여하지 않은 경우 clientId로 식별되는 애플리케이션에 EE 데이터에 대한 액세스 권한을 부여하라는 메시지가 표시됩니다.
이 인증 방법 또는 다른 인증 방법은 ee.initialize() 전에 호출해야 합니다.
사용자가 이전에 클라이언트 ID로 식별되는 애플리케이션에 대한 액세스 권한을 부여하지 않은 경우 기본적으로 사용자에게 필요한 권한을 부여하라는 메시지가 표시된 대화상자 창이 팝업으로 표시됩니다. 하지만 이 팝업은 브라우저에서 차단할 수 있습니다. 이를 방지하려면 opt_onImmediateFailed 콜백을 지정하고 콜백에서 인페이지 로그인 버튼을 렌더링한 다음 이 버튼의 클릭 이벤트 핸들러에서 ee.data.authenticateViaPopup()을 호출하세요. 이제 팝업이 사용자 작업의 직접적인 결과이므로 브라우저에서 팝업을 차단하지 않습니다.
가능한 경우 인증 토큰이 자동으로 새로고침됩니다. 모든 비동기 호출이 적절한 사용자 인증 정보와 함께 전송된다고 가정해도 안전합니다. 하지만 동기 호출의 경우 ee.data.getAuthToken()으로 인증 토큰을 확인하고 없는 경우 ee.data.refreshAuthToken()을 수동으로 호출해야 합니다. 토큰 새로고침 작업은 비동기식이며 동기식 호출 전에 주문형으로 백그라운드에서 실행할 수 없습니다.
사용 | 반환 값 |
---|
ee.data.authenticateViaOauth(clientId, success, error, extraScopes, onImmediateFailed, suppressDefaultScopes) | |
인수 | 유형 | 세부정보 |
---|
clientId | 문자열 | 애플리케이션의 OAuth 클라이언트 ID입니다. 인증된 호출을 사용 중지하려면 null을 사용하세요. 이 값은 Google Developers Console을 통해 확인할 수 있습니다. 프로젝트에는 스크립트가 실행되는 도메인에 해당하는 JavaScript 출처가 있어야 합니다. |
success | 함수 | 인증이 성공한 경우 호출할 함수입니다. |
error | 함수(선택사항) | 인증이 실패한 경우 호출할 함수입니다. 오류 메시지가 전달됩니다. 즉시(백그라운드) 모드에서 인증이 실패하고 opt_onImmediateFailed가 지정된 경우 opt_error 대신 해당 함수가 호출됩니다. |
extraScopes | List<String>, 선택사항 | 요청할 추가 OAuth 범위입니다. |
onImmediateFailed | 함수(선택사항) | 자동 백그라운드 인증이 실패할 경우 호출할 함수입니다. 전달된 콜백에 바인딩된 ee.data.authenticateViaPopup()이 기본값입니다. |
suppressDefaultScopes | 불리언, 선택사항 | true인 경우 opt_extraScopes에 지정된 범위만 요청됩니다. opt_extraScopes에 명시적으로 지정되지 않는 한 기본 범위는 요청되지 않습니다. |
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-25(UTC)
[null,null,["최종 업데이트: 2025-07-25(UTC)"],[[["\u003cp\u003eEnables authenticated access to Earth Engine data using your Google account via the Google APIs Client Library for JavaScript.\u003c/p\u003e\n"],["\u003cp\u003eRequires initialization before using Earth Engine functionalities and might prompt users for permission to access their Earth Engine data.\u003c/p\u003e\n"],["\u003cp\u003eAutomatically refreshes authentication tokens for asynchronous calls, but synchronous calls may require manual token refresh using \u003ccode\u003eee.data.getAuthToken()\u003c/code\u003e and \u003ccode\u003eee.data.refreshAuthToken()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eProvides options for handling authentication failures, including specifying custom error callbacks and displaying an in-page login button to avoid browser popup blockers.\u003c/p\u003e\n"],["\u003cp\u003eAllows customization of OAuth scopes and client ID for specific application requirements.\u003c/p\u003e\n"]]],[],null,["# ee.data.authenticateViaOauth\n\n\u003cbr /\u003e\n\nConfigures client-side authentication of EE API calls through the Google APIs Client Library for JavaScript. The library will be loaded automatically if it is not already loaded on the page. The user will be asked to grant the application identified by clientId access to their EE data if they have not done so previously.\n\n\u003cbr /\u003e\n\nThis or another authentication method should be called before ee.initialize().\n\nNote that if the user has not previously granted access to the application identified by the client ID, by default this will try to pop up a dialog window prompting the user to grant the required permission. However, this popup can be blocked by the browser. To avoid this, specify the opt_onImmediateFailed callback, and in it render an in-page login button, then call ee.data.authenticateViaPopup() from the click event handler of this button. This stops the browser from blocking the popup, as it is now the direct result of a user action.\n\nThe auth token will be refreshed automatically when possible. You can safely assume that all async calls will be sent with the appropriate credentials. For synchronous calls, however, you should check for an auth token with ee.data.getAuthToken() and call ee.data.refreshAuthToken() manually if there is none. The token refresh operation is asynchronous and cannot be performed behind-the-scenes on-demand prior to synchronous calls.\n\n| Usage | Returns |\n|------------------------------------------------------------------------------------------------------------------------------------|---------|\n| `ee.data.authenticateViaOauth(clientId, success, `*error* `, `*extraScopes* `, `*onImmediateFailed* `, `*suppressDefaultScopes*`)` | |\n\n| Argument | Type | Details |\n|-------------------------|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `clientId` | String | The application's OAuth client ID, or null to disable authenticated calls. This can be obtained through the Google Developers Console. The project must have a JavaScript origin that corresponds to the domain where the script is running. |\n| `success` | Function | The function to call if authentication succeeded. |\n| `error` | Function, optional | The function to call if authentication failed, passed the error message. If authentication in immediate (behind-the-scenes) mode fails and opt_onImmediateFailed is specified, that function is called instead of opt_error. |\n| `extraScopes` | List\\\u003cString\\\u003e, optional | Extra OAuth scopes to request. |\n| `onImmediateFailed` | Function, optional | The function to call if automatic behind-the-scenes authentication fails. Defaults to ee.data.authenticateViaPopup(), bound to the passed callbacks. |\n| `suppressDefaultScopes` | Boolean, optional | When true, only scopes specified in opt_extraScopes are requested; the default scopes are not requested unless explicitly specified in opt_extraScopes. |"]]