Created
May 31, 2021 06:04
-
-
Save s875515/623b3273ff541b961f2692cb863072fb to your computer and use it in GitHub Desktop.
youtube api update csr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetchAuth = useCallback(() => { | |
(global as any).gapi.auth2 | |
.getAuthInstance() | |
.signIn({ scope: "https://www.googleapis.com/auth/youtubepartner" }) | |
.then( | |
() => { | |
console.log("Sign-in successful"); | |
(global as any).gapi.client.setApiKey(config.GOOGLE_API_KEY); | |
(global as any).gapi.client | |
.load( | |
"https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest" | |
) | |
.then( | |
() => { | |
console.log("GAPI client loaded for API"); | |
(global as any).gapi.client.youtube.videos | |
.update({ | |
part: ["snippet"], | |
resource: { | |
id: "c_CGrAolMho", | |
snippet: { | |
title: "test00000", | |
categoryId: "2", | |
}, | |
}, | |
}) | |
.then((res: any) => { | |
console.log(res); | |
}), | |
(err: any) => { | |
console.log(err); | |
}; | |
}, | |
(err: any) => { | |
console.error("Error loading GAPI client for API", err); | |
} | |
); | |
}, | |
(err: any) => { | |
console.error("Error signing in", err); | |
} | |
); | |
}, []); | |
useEffect(() => { | |
fetchAuth(); | |
}, [fetchAuth]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment