def build_integration(self, state): identity = state['identity']['data'] user = get_user_info(identity['access_token']) installation = self.get_installation_info( identity['access_token'], state['installation_id']) integration = { 'name': installation['account']['login'], # TODO(adhiraj): This should be a constant representing the entire github cloud. 'external_id': installation['id'], # GitHub identity is associated directly to the application, *not* # to the installation itself. 'idp_external_id': installation['app_id'], 'metadata': { # The access token will be populated upon API usage 'access_token': None, 'expires_at': None, 'icon': installation['account']['avatar_url'], 'domain_name': installation['account']['html_url'].replace('https://', ''), 'account_type': installation['account']['type'], }, 'user_identity': { 'type': 'github', 'external_id': user['id'], 'scopes': [], # GitHub apps do not have user scopes 'data': {'access_token': identity['access_token']}, }, } if state.get('reinstall_id'): integration['reinstall_id'] = state['reinstall_id'] return integration
def build_integration(self, state): identity = state['identity']['data'] user = get_user_info(identity['access_token']) installation = self.get_installation_info(identity['access_token'], state['installation_id']) return { 'name': installation['account']['login'], 'external_id': installation['id'], 'metadata': { # The access token will be populated upon API usage 'access_token': None, 'expires_at': None, 'icon': installation['account']['avatar_url'], 'domain_name': installation['account']['html_url'].replace('https://', ''), }, 'user_identity': { 'type': 'github', 'external_id': user['id'], 'scopes': [], # GitHub apps do not have user scopes 'data': { 'access_token': identity['access_token'] }, }, }
def build_integration(self, state): identity = state["identity"]["data"] user = get_user_info(identity["access_token"]) installation = self.get_installation_info(identity["access_token"], state["installation_id"]) integration = { "name": installation["account"]["login"], # TODO(adhiraj): This should be a constant representing the entire github cloud. "external_id": installation["id"], # GitHub identity is associated directly to the application, *not* # to the installation itself. "idp_external_id": installation["app_id"], "metadata": { # The access token will be populated upon API usage "access_token": None, "expires_at": None, "icon": installation["account"]["avatar_url"], "domain_name": installation["account"]["html_url"].replace("https://", ""), "account_type": installation["account"]["type"], }, "user_identity": { "type": "github", "external_id": user["id"], "scopes": [], # GitHub apps do not have user scopes "data": { "access_token": identity["access_token"] }, }, } if state.get("reinstall_id"): integration["reinstall_id"] = state["reinstall_id"] return integration