Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub (Enterprise) fixes #18

Closed
wants to merge 3 commits into from
Closed

Conversation

cyb3rko
Copy link

@cyb3rko cyb3rko commented Jan 5, 2024

Fixes #16
And fixes one part of #17 (wrong URLs when clicking the author names)

@mihaigalos
Copy link

Hi @cyb3rko: did you actually get this running? The URLs to users profiles seem fixed with your changes, but I still cannot download users' avatars. Tried manually downloading it with curl (even with a bearer token) - nope.

Seems this is a known problem for GitHub Enterprise: octokit/octokit.js#2061 (comment).

@mihaigalos
Copy link

I got this running by scripting Selenium.

Details

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
import time
import os

start_url = "https://idp.company.com/idp/startSSO.ping?PartnerSpId=https://github.company.com"
username = "none"
password = os.getenv("GH_TOKEN")
avatar_url = "https://avatars.github.company.com/u/9214?&size=32"
download_path = "avatar.jpg"

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--disable-notifications")
chrome_options.add_argument("--window-size=1920,1080")

driver = webdriver.Chrome(options=chrome_options)

try:
    driver.get(start_url)
    time.sleep(3)

    location_dropdown = Select(driver.find_element(By.ID, "location"))
    location_dropdown.select_by_value("HO")
    time.sleep(1)

    sign_on_button = driver.find_element(By.CSS_SELECTOR, "a.ping-button.normal.allow[title='Sign On']")
    sign_on_button.click()
    time.sleep(5)

    driver.get(avatar_url)
    time.sleep(3)

    avatar_element = driver.find_element(By.TAG_NAME, "img")
    with open(download_path, "wb") as file:
        file.write(avatar_element.screenshot_as_png)

    print(f"Avatar downloaded successfully to {download_path}.")

finally:
    driver.quit()

@mihaigalos
Copy link

Also, this seems to run when rendering from CI and pushing to gh-pages.
That's because the user's browser is authenticated via the OAuth workflow and thus the icons load.

They only locally don't work.

@cyb3rko
Copy link
Author

cyb3rko commented Sep 28, 2024

Hello @mihaigalos,

I remember having issues with the avatars, but I'm currently not sure if I fixed it or not.
Next week I will check again on the wiki I built and come back to you.

@timvink
Copy link
Contributor

timvink commented Sep 29, 2024

Fyi this repo had been forked, the fork has support for avatars and is actively maintained https://github.com/ojacques/mkdocs-git-committers-plugin-2

@cyb3rko
Copy link
Author

cyb3rko commented Sep 29, 2024

Fyi this repo had been forked, the fork has support for avatars and is actively maintained https://github.com/ojacques/mkdocs-git-committers-plugin-2

Nice, good to know. Then I can close this here as it seems to be implemented in https://github.com/ojacques/mkdocs-git-committers-plugin-2

@cyb3rko cyb3rko closed this Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecation warning for GitHub login
3 participants