사용자 ID 속성 액세스
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
사용자는 커뮤니티 커넥터를 사용하여 자체 데이터 소스를 만듭니다. 이러한 데이터 소스의 경우 커넥터는 유효 사용자의 ID에 액세스할 수 있습니다.
데이터 소스 사용자 인증 정보에 따라 유효 사용자는 데이터 소스 생성자 (소유자의 사용자 인증 정보) 또는 보고서 뷰어 (조회자의 사용자 인증 정보)가 될 수 있습니다.
이점
- 사용자 대신 Google 서비스 및 API에 액세스할 수 있습니다.
- 관련 데이터만 표시되도록 커스텀 액세스 제어를 구현할 수 있습니다.
- 효과적인 사용자를 위해 사용자 환경을 맞춤설정할 수 있습니다.
구현 단계
사용자 OAuth 토큰 액세스
커넥터는 사용자의 OAuth 토큰을 전달하여 사용자를 대신하여 Google 서비스 및 API에 액세스할 수 있습니다. 커넥터에서 유효 사용자의 OAuth 토큰에 액세스하려면 ScriptApp.getOAuthToken()
를 사용합니다. getOAuthToken 참조를 확인하세요.
이 토큰에는 커넥터 승인 중에 포함된 승인 범위가 포함됩니다.
대부분의 커넥터에서 Apps Script는 스크립트를 파싱하고 처리하여 필요한 범위를 자동으로 감지합니다. 언제든지 커넥터에서 사용하는 범위를 볼 수 있습니다. 매니페스트에서 URL 문자열을 사용하여 범위를 명시적으로 설정할 수도 있습니다. 사용자를 대신하여 Google 서비스 또는 API에 액세스하려면 관련 범위를 매니페스트에 포함합니다.
사용자 이메일 주소 액세스
코드에서 Session.getEffectiveUser().getEmail()
로 현재의 유효 사용자를 식별할 수 있습니다. geteffectiveUser 참조를 확인하세요.
이 코드를 추가하면 https://www.googleapis.com/auth/userinfo.email
승인 범위가 커넥터에 자동으로 추가됩니다.
예: 사용자 OAuth 토큰으로 Google API 호출
- Google 피트니스 커넥터는 유효 사용자를 위해 Google 피트니스 API에서 데이터를 가져옵니다. API를 호출하는 동안 유효 사용자의 OAuth 토큰이 전달됩니다. 구현에 관한 자세한 내용은 소스 코드를 참고하세요.
- Firestore 커넥터는 Cloud Resource Manager를 사용하여 유효 사용자의 프로젝트 목록을 가져옵니다. 이 커넥터는 유효 사용자의 OAuth 토큰도 전달합니다. 구현에 관한 자세한 내용은 소스 코드를 참고하세요.
예: 이메일 주소 기준 isAdminUser()
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-25(UTC)
[null,null,["최종 업데이트: 2025-07-25(UTC)"],[[["\u003cp\u003eCommunity Connectors allow you to build data sources that can access the effective user's identity, enabling personalized data retrieval.\u003c/p\u003e\n"],["\u003cp\u003eDepending on the data source credentials, the effective user can be either the data source creator or the report viewer.\u003c/p\u003e\n"],["\u003cp\u003eYour connector can leverage the user's OAuth token to access Google services and APIs on their behalf for custom data integrations.\u003c/p\u003e\n"],["\u003cp\u003eYou can tailor the user experience by implementing custom access control and using the user's email address for identification.\u003c/p\u003e\n"]]],[],null,["# Access user identity properties\n\nUsers will use your Community Connector to create their own data sources. For\nthese data sources, your connector can access the effective user's identity.\nDepending on the [Data source credentials](https://support.google.com/looker-studio/answer/6371135), the effective user can be the data\nsource creator (Owner's credentials) or the report viewer (Viewer's\ncredentials).\n\nBenefits\n--------\n\n- You can access Google services and APIs on behalf of the user.\n- You can implement custom access control to ensure only relevant data is being displayed.\n- You can customize the user experience for the effective user.\n\nImplementation steps\n--------------------\n\n### Accessing the user OAuth token\n\nYour connector can access Google services and APIs on behalf of the user by\npassing the user's OAuth token. To access the effective user's OAuth token in\nyour connector, use `ScriptApp.getOAuthToken()`. See [getOAuthToken reference](/apps-script/reference/script/script-app#getoauthtoken).\nThis token will include the [Authorization scopes](/apps-script/concepts/scopes) included during the connector\nauthorization.\n\nFor most connectors, Apps Script automatically detects what scopes are needed by\nparsing and processing the script. You can [view the scopes](/apps-script/concepts/scopes#viewing_scopes) a connector uses at\nany time. You can also [set scopes explicitly](/apps-script/concepts/scopes#setting_explicit_scopes) in your [manifest](/apps-script/concepts/manifests) using URL\nstrings. If you want to access a Google service or API on behalf of the user,\ninclude that relevant scope in the manifest.\n\n### Accessing the user email address\n\nIn your code, you can identify the current effective user with\n`Session.getEffectiveUser().getEmail()`. See [getEffectiveUser reference](/apps-script/reference/base/session#getEffectiveUser).\nAdding this code will automatically add the\n`https://www.googleapis.com/auth/userinfo.email` authorization scope to your\nconnector.\n\nExample: Calling Google APIs with user OAuth token\n--------------------------------------------------\n\n- The [Google Fit connector](https://lookerstudio.google.com/datasources/create?connectorId=AKfycbwFrL1OLXR3wqfnxowGFF3w3D4eq-54vAwjxDWcWRjiZMxX7jhII_1Ddx6y76GDHrxIew) fetches data from the Google Fit API for the effective user. While calling the API, it passes the effective user's OAuth token. See [the source code](https://github.com/googledatastudio/community-connectors/blob/master/google-fit/src/GoogleFit.js#L245) for implementation details.\n- The [Firestore connector](https://github.com/googledatastudio/community-connectors/tree/master/firestore) uses the Cloud Resource Manager to get a list of projects for the effective user. This connector also passes the effective user's OAuth token. See [the source code](https://github.com/googledatastudio/community-connectors/blob/master/firestore/src/GoogleCloud.gs#L30) for implementation details.\n\nExample: `isAdminUser()` based on email address\n-----------------------------------------------\n\n- The [Chrome UX Connector](http://g.co/chromeuxdash) maintains a list of admin users. It uses `getEffectiveUser()` and compares the effective user against the list to determine whether the effective user is an admin or not. See [implementation of `getEffectiveUser`](https://github.com/googledatastudio/community-connectors/blob/master/chrome-ux-report/src/Code.js#L581)."]]