def build_integration(self, state): identity = state['identity']['data'] installation_data = state['installation_data'] user = get_user_info(installation_data['url'], identity['access_token']) installation = self.get_installation_info( installation_data, identity['access_token'], state['installation_id']) return { 'name': installation['account']['login'], '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://', '').split("/")[0], 'installation': installation_data }, 'user_identity': { 'type': 'github-enterprise', 'external_id': user['id'], 'scopes': [], # GitHub apps do not have user scopes 'data': {'access_token': identity['access_token']}, }, 'idp_config': state['oauth_config_information'] }
def build_integration(self, state): identity = state['identity']['data'] installation_data = state['installation_data'] user = get_user_info(installation_data['url'], identity['access_token']) installation = self.get_installation_info( installation_data, identity['access_token'], state['installation_id']) domain = urlparse(installation['account']['html_url']).netloc return { 'name': installation['account']['login'], # installation id is not enough to be unique for self-hosted GH 'external_id': '{}:{}'.format(domain, installation['id']), # GitHub identity is associated directly to the application, *not* # to the installation itself. # app id is not enough to be unique for self-hosted GH 'idp_external_id': '{}:{}'.format(domain, 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'], 'installation_id': installation['id'], 'installation': installation_data }, 'user_identity': { 'type': 'github_enterprise', 'external_id': user['id'], 'scopes': [], # GitHub apps do not have user scopes 'data': {'access_token': identity['access_token']}, }, 'idp_config': state['oauth_config_information'] }
def build_integration(self, state): identity = state["identity"]["data"] installation_data = state["installation_data"] user = get_user_info(installation_data["url"], identity["access_token"]) installation = self.get_installation_info(installation_data, identity["access_token"], state["installation_id"]) domain = urlparse(installation["account"]["html_url"]).netloc integration = { "name": installation["account"]["login"], # installation id is not enough to be unique for self-hosted GH "external_id": u"{}:{}".format(domain, installation["id"]), # GitHub identity is associated directly to the application, *not* # to the installation itself. # app id is not enough to be unique for self-hosted GH "idp_external_id": u"{}:{}".format(domain, 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"], "installation_id": installation["id"], "installation": installation_data, }, "user_identity": { "type": "github_enterprise", "external_id": user["id"], "scopes": [], # GitHub apps do not have user scopes "data": { "access_token": identity["access_token"] }, }, "idp_config": state["oauth_config_information"], } if state.get("reinstall_id"): integration["reinstall_id"] = state["reinstall_id"] return integration
def build_integration(self, state): identity = state['identity']['data'] installation_data = state['installation_data'] user = get_user_info(installation_data['url'], identity['access_token']) installation = self.get_installation_info(installation_data, identity['access_token'], state['installation_id']) domain = urlparse(installation['account']['html_url']).netloc integration = { 'name': installation['account']['login'], # installation id is not enough to be unique for self-hosted GH 'external_id': u'{}:{}'.format(domain, installation['id']), # GitHub identity is associated directly to the application, *not* # to the installation itself. # app id is not enough to be unique for self-hosted GH 'idp_external_id': u'{}:{}'.format(domain, 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'], 'installation_id': installation['id'], 'installation': installation_data }, 'user_identity': { 'type': 'github_enterprise', 'external_id': user['id'], 'scopes': [], # GitHub apps do not have user scopes 'data': { 'access_token': identity['access_token'] }, }, 'idp_config': state['oauth_config_information'] } if state.get('reinstall_id'): integration['reinstall_id'] = state['reinstall_id'] return integration