@@ -101,7 +101,7 @@ user: PublicUser | PrivateUser = resp.parsed_data
101
101
data: dict = github.graphql(" { viewer { login } }" )
102
102
```
103
103
104
- ### Develop an OAuth APP with web flow
104
+ ### Develop an OAuth APP (GitHub APP) with web flow
105
105
106
106
``` python
107
107
from githubkit.versions.latest.models import PublicUser, PrivateUser
@@ -119,6 +119,15 @@ auth: OAuthTokenAuthStrategy = github.auth.as_web_user("<code>").exchange_token(
119
119
access_token = auth.token
120
120
refresh_token = auth.refresh_token
121
121
# restore the user token from database
122
+
123
+ # when using OAuth APP or GitHub APP without user-to-server token expiration
124
+ user_github = github.with_auth(
125
+ OAuthTokenAuthStrategy(
126
+ " <client_id>" , " <client_secret>" , token = access_token
127
+ )
128
+ )
129
+ # OR when using GitHub APP with user-to-server token expiration
130
+ # you can use the refresh_token to generate a new token
122
131
user_github = github.with_auth(
123
132
OAuthTokenAuthStrategy(
124
133
" <client_id>" , " <client_secret>" , refresh_token = refresh_token
@@ -128,6 +137,9 @@ user_github = github.with_auth(
128
137
# now you can act as the user
129
138
resp = user_github.rest.users.get_authenticated()
130
139
user: PublicUser | PrivateUser = resp.parsed_data
140
+
141
+ # you can get the user login id now
142
+ login_id = user.login
131
143
```
132
144
133
145
### Develop an OAuth APP with device flow
0 commit comments