Skip to content

Commit 7942c52

Browse files
committed
quick fix github limit
1 parent e97d216 commit 7942c52

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/github/app.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub struct GitHubUser {
6464

6565
fn id_to_username(
6666
id: web::Path<String>,
67+
gtihub_auth_params: web::Data<String>,
6768
cache: web::Data<Arc<RwLock<TtlCache<String, String>>>>,
6869
) -> impl Future<Item = HttpResponse, Error = Error> {
6970
if let Some(username) = cache.read().ok().and_then(|c| c.get(&*id).cloned()) {
@@ -74,7 +75,7 @@ fn id_to_username(
7475
let cache_id = (*id).clone();
7576
Either::B(
7677
Client::default()
77-
.get(format!("{}/{}", USER_URL, id))
78+
.get(format!("{}/{}{}", USER_URL, id, *gtihub_auth_params))
7879
.header(http::header::USER_AGENT, "whoami")
7980
.send()
8081
.map_err(Into::into)
@@ -199,6 +200,10 @@ pub fn github_app<T: AsyncCisClientTrait + 'static>(
199200
let github_client_secret = ClientSecret::new(github.client_secret.clone());
200201
let auth_url = AuthUrl::new(Url::parse(AUTH_URL).expect("Invalid authorization endpoint URL"));
201202
let token_url = TokenUrl::new(Url::parse(TOKEN_URL).expect("Invalid token endpoint URL"));
203+
let gtihub_auth_params = format!(
204+
"?client_id={}&client_secret={}",
205+
&github.client_id, &github.client_secret
206+
);
202207

203208
let client = Arc::new(
204209
BasicClient::new(
@@ -235,6 +240,7 @@ pub fn github_app<T: AsyncCisClientTrait + 'static>(
235240
.data(client)
236241
.data(cis_client)
237242
.data(ttl_cache)
243+
.data(gtihub_auth_params)
238244
.service(web::resource("/add").route(web::get().to(redirect)))
239245
.service(web::resource("/auth").route(web::get().to_async(auth::<T>)))
240246
.service(web::resource("/username/{id}").route(web::get().to_async(id_to_username)))

0 commit comments

Comments
 (0)