MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / ApplicationOAuth

Class ApplicationOAuth

github/ApplicationOAuth.py:48–198  ·  view source on GitHub ↗

This class is used for identifying and authorizing users for Github Apps. The reference can be found at https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps

Source from the content-addressed store, hash-verified

46
47
48class ApplicationOAuth(NonCompletableGithubObject):
49 """
50 This class is used for identifying and authorizing users for Github Apps.
51
52 The reference can be found at
53 https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps
54
55 """
56
57 def __init__(
58 self,
59 requester: Requester,
60 headers: dict[str, Any],
61 attributes: Any,
62 ) -> None:
63 # this object requires a request without authentication
64 requester = requester.withAuth(auth=None)
65 super().__init__(requester, headers, attributes)
66
67 def _initAttributes(self) -> None:
68 self._client_id: Attribute[str] = NotSet
69 self._client_secret: Attribute[str] = NotSet
70
71 def __repr__(self) -> str:
72 return self.get__repr__({"client_id": self._client_id.value})
73
74 @property
75 def client_id(self) -> str:
76 return self._client_id.value
77
78 @property
79 def client_secret(self) -> str:
80 return self._client_secret.value
81
82 def get_oauth_url(self, path: str) -> str:
83 if not path.startswith("/"):
84 path = f"/{path}"
85
86 if self._requester.base_url == DEFAULT_BASE_URL:
87 base_url = DEFAULT_OAUTH_URL
88 else:
89 base_url = f"{self._requester.scheme}://{self._requester.hostname_and_port}/login/oauth"
90 return f"{base_url}{path}"
91
92 def get_login_url(
93 self,
94 redirect_uri: str | None = None,
95 state: str | None = None,
96 login: str | None = None,
97 ) -> str:
98 """
99 Return the URL you need to redirect a user to in order to authorize your App.
100 """
101 parameters = {"client_id": self.client_id}
102 if redirect_uri is not None:
103 assert isinstance(redirect_uri, str), redirect_uri
104 parameters["redirect_uri"] = redirect_uri
105 if state is not None:

Callers 1

withRequesterMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…