Skip to content

Commit

Permalink
chore: add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushtom committed Dec 1, 2023
1 parent 1fa5412 commit 69255b7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/endpoints/quests/focustree/engagement/discord_fw_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub async fn handler(
state.conf.variables.app_link, quest_id, task_id
);

println!("Authorization code: {}", authorization_code);

// Exchange the authorization code for an access token
let params = [
("client_id", &state.conf.discord.oauth2_clientid),
Expand All @@ -54,9 +56,16 @@ pub async fn handler(
),
("grant_type", &"authorization_code".to_string()),
];

println!("Params: {:?}", params);

let access_token = match exchange_authorization_code(params).await {
Ok(token) => token,
Ok(token) => {
println!("Access token: {}", token);
token
},
Err(e) => {
println!("Failed to exchange authorization code: {}", e);
return get_error_redirect(
error_redirect_uri,
format!("Failed to exchange authorization code: {}", e),
Expand Down Expand Up @@ -95,6 +104,7 @@ pub async fn handler(
}
};


for guild in response {
if guild.id == guild_id {
match state.upsert_completed_task(query.state, task_id).await {
Expand All @@ -105,7 +115,10 @@ pub async fn handler(
);
return success_redirect(redirect_uri);
}
Err(e) => return get_error_redirect(error_redirect_uri, format!("{}", e)),
Err(e) => {
println!("Guild Error: {}", e);
return get_error_redirect(error_redirect_uri, format!("{}", e))
},
}
}
}
Expand Down

0 comments on commit 69255b7

Please sign in to comment.