Hello. First time asking a question in the community. I would like to create a native android app displaying videos from my YouTube channel. I am having a difficult time figuring out how to get the access token.
Here is what I have figured out so far.
1. I know which APIs to call.
https://developers.google.com/youtube/v3/docs/channels/list
https://developers.google.com/youtube/v3/docs/playlistItems/list
2. I created curls for these APIs
GetYouTubeChannelsList
curl --location -g --request GET 'https://youtube.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername={YOUR_USER_NAME}&key={YOUR_API_KEY}' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json'
GetYouTubePlaylistItems
curl --location -g --request GET 'https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId={YOUR_PLAYLIST_ID}&key={YOUR_API_KEY}' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json'
Due to not knowing where I can receive the access token, I am stuck.
3. I found a google api client library that seems to allow authentication behind the scenes, where you can receive an access token by only providing your api key which you generate on Google Cloud console. However, the class is deprecated.
implementation 'com.google.api-client:google-api-client:1.34.0'
The `GoogleCredential` class is deprecated.
4. After further research, I found another auth library. I thought that maybe this was a replacement for GoogleCrediential. However, I do not understand how to use it. What steps do I need to do exactly for GoogleCredentials.getApplicationDefault() to work?
implementation 'com.google.auth:google-auth-library-oauth2-http:0.17.1'
Unfortunately, there isn’t too many code examples online.
My ASKs
(1) I would like to add an access token to my curl script and get a successful response.
(2) I would like to know which libraries should be used for the type of application I want to build.
Best answer by ilias
View original