score:0
using mine will require that you are authorized as a user in order to request that data. an api key will only give you access to public data not private data
<script src="https://apis.google.com/js/api.js"></script>
<script>
/**
* sample javascript code for youtube.playlists.list
* see instructions for running apis explorer code samples locally:
* https://developers.google.com/explorer-help/guides/code_samples#javascript
*/
function authenticate() {
return gapi.auth2.getauthinstance()
.signin({scope: "https://www.googleapis.com/auth/youtube.readonly"})
.then(function() { console.log("sign-in successful"); },
function(err) { console.error("error signing in", err); });
}
function loadclient() {
gapi.client.setapikey("your_api_key");
return gapi.client.load("https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest")
.then(function() { console.log("gapi client loaded for api"); },
function(err) { console.error("error loading gapi client for api", err); });
}
// make sure the client is loaded and sign-in is complete before calling this method.
function execute() {
return gapi.client.youtube.playlists.list({})
.then(function(response) {
// handle the results here (response.result has the parsed body).
console.log("response", response);
},
function(err) { console.error("execute error", err); });
}
gapi.load("client:auth2", function() {
gapi.auth2.init({client_id: "your_client_id"});
});
</script>
<button onclick="authenticate().then(loadclient)">authorize and load</button>
<button onclick="execute()">execute</button>
</body>
</html>
score:0
to use mine,set authorization in header. check this!
https://accounts.google.com/o/oauth2/auth?
client_id=123456789-sdnjknsdkjf4skfnsdjnsfdksdkjl.apps.googleusercontent.com&
redirect_uri=http%3a%2f%2flocalhost%2foauth2callback&
scope=https://www.googleapis.com/auth/youtube&
response_type=token
const res = await fetch('https://content-youtube.googleapis.com/youtube/v3/channels
mine=true&part=statistics&key=asdasdasd',
{ headers: { authorization: `bearer ${token}` } },);
Source: stackoverflow.com
Related Query
- how to use youtube data api v3 parameter mine
- How to use getStaticProps in _app.js for showing data fetched from api in every pages in Next.js
- How to use useEffect() to fetch data from an api in a useReducer() and useContext() state management setup?
- How to use TypeScript types on API response data
- How to Fix Youtube Data API v3 Required Parameter: part in Axios request and React.js
- How to prevent use my API which gives data for my React app
- How do I use startsWith with a form submission when filtering array data from an API in React?
- How to use a data from the 1st API call and use that in my 2nd API call?
- How to use highcharts in reactjs with fetched data from API
- How can we specifically use the data comes from the api in the map function?
- React: how to use axios/fetch to get data from API that runs on localhost?
- How to use pagination in react so that my data from api should be paginated accordingly
- How to extract text input value and pass down that value down to a child component as a prop to use for fetching third part api data in React?
- how do i turn data from my api to array i cant use map function so i want to turn cart.cartItems into an array
- How to use Datatable in Reactjs when the data from API
- How do I use the returned value from the first API call as a parameter to the second API call?
- How can I turn the data that is a image came from API to url to use in img tag in react Js
- How do I convert React API data to props for use in other components?
- How do I use the Contentful api data with React Context API (useContext in particular)?
- How do I use react context API to pass data from parent component to child component when using react-router in the parent component in React.js?
- How to get user data from API to use in a React app?
- i have data in my shopify api i want to use that data in my reactjs app how do i do that
- How can I use response data from an API to call another different API request in React UseEffect?
- How can I add my query parameter data -which I use in URL- to my response data?
- How to use setState to render individual data returned from API call using map
- React, How to use a menu in a seperate file to call an api and return data to a different section of the main file
- How to call a GET api with string parameter after I login and passing the email address so the data will come out? (REACT.js)
- How to use REST API data with moment isBetween to update open/closing times
- How do i set the state from one API call and use the data for URL in next API call?
- How to use `React.createElement` children parameter (without jsx)
More Query from same tag
- Pages are reloaded instead of routed in shopify next js app
- Add and delete value from an array in react dynamically
- useEffect cleanup never called when using Electron
- React img not immediately changing when src changes. How can I fix this?
- Normalizr - How to generate slug/id related to parent entity
- React-apollo update not reloading after mutation if I transform data before the render()
- Using returned values from static React function
- react-file-viewer does not load a new document on filePath change
- Problem in using useReducer and useContext hooks to make a shopping cart
- React + modal: input field auto focus
- Error connect to Spring-boot-Rsocket (Auth JWT) from web-client RSocketWebSocketClient
- How to use a dispatch (react-redux) into class Component
- Cross Component Communication Architecture with Apollo, Graphql
- Navbar component being shown everytime the page loads
- How to update/manage data for react-table - useRowState plugin behaviour is unclear
- React-Time-Range Only Shows Default Start Time
- Where to call Sentry.configureScope?
- Why unhandledrejection event can not catch some Error in React?
- static inside React component
- Render JSX-elements as multi-level pyramid
- componentDidMount called before real DOM is available
- How to put bullets only between items in a wrapping, in-line list
- Access state from Event Handler created within React.js UseEffect Hook
- Material UI Raised Button not working
- How to create a function for sorting an array of object by some property in reactjs?
- React.js : Passing Props from a Function to a Component
- react js cannot get updated value in setState callback function
- React doesn't show component in Laravel 5.8 blade
- Uncaught TypeError: this.context.router.push is not a function
- Nextjs - await store.dispatch Cannot read property 'dispatch' of undefined