File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -466,6 +466,8 @@ const filterUsers = async (req, res) => {
466
466
467
467
// one time script function to perform the migration - adding github_user_id field to the document
468
468
const migrate = async ( req , res ) => {
469
+ const authToken = `${ config . get ( "githubOauth.clientId" ) } :${ config . get ( "githubOauth.clientSecret" ) } ` ;
470
+ const base64 = Buffer . from ( `${ authToken } ` , "binary" ) . toString ( "base64" ) ;
469
471
try {
470
472
// Fetch user data from GitHub API for each document in the users collection
471
473
// divided by 500 because firestore api guarantee that we can process in batch of 500.
@@ -481,7 +483,12 @@ const migrate = async (req, res) => {
481
483
batchWrite . update ( userDoc . ref , { github_user_id : null } ) ;
482
484
batchWrites . push (
483
485
axios
484
- . get ( `https://api.github.com/users/${ githubUsername } ` )
486
+ . get ( `https://api.github.com/users/${ githubUsername } ` , {
487
+ headers : {
488
+ "Content-Type" : "application/json" ,
489
+ auth : `Bearer ${ base64 } ` ,
490
+ } ,
491
+ } )
485
492
. then ( ( response ) => {
486
493
const githubUserId = response . data . id ;
487
494
batchWrite . update ( userDoc . ref , { github_user_id : `${ githubUserId } ` } ) ;
You can’t perform that action at this time.
0 commit comments