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

Method get_access_token

github/ApplicationOAuth.py:116–143  ·  view source on GitHub ↗

:calls: `POST /login/oauth/access_token `_

(self, code: str, state: str | None = None)

Source from the content-addressed store, hash-verified

114 return self.get_oauth_url(f"/authorize?{query}")
115
116 def get_access_token(self, code: str, state: str | None = None) -> AccessToken:
117 """
118 :calls: `POST /login/oauth/access_token <https://docs.github.com/en/developers/apps/identifying-and-authorizing-users-for-github-apps>`_
119 """
120 assert isinstance(code, str), code
121 post_parameters = {
122 "code": code,
123 "client_id": self.client_id,
124 "client_secret": self.client_secret,
125 }
126
127 if state is not None:
128 post_parameters["state"] = state
129
130 headers, data = self._checkError(
131 *self._requester.requestJsonAndCheck(
132 "POST",
133 self.get_oauth_url("/access_token"),
134 headers={"Accept": "application/json"},
135 input=post_parameters,
136 )
137 )
138
139 return github.AccessToken.AccessToken(
140 requester=self._requester,
141 headers=headers,
142 attributes=data,
143 )
144
145 def get_app_user_auth(self, token: AccessToken) -> AppUserAuth:
146 return github.Auth.AppUserAuth(

Calls 3

_checkErrorMethod · 0.95
get_oauth_urlMethod · 0.95
requestJsonAndCheckMethod · 0.80

Tested by

no test coverage detected