Skip to content

Commit

Permalink
Merge pull request #35 from ncsa/179-allow-youtube-api-keys-graphql
Browse files Browse the repository at this point in the history
add api key
  • Loading branch information
longshuicy authored Jul 17, 2024
2 parents 9b2ce34 + 691bb79 commit 7f38a4e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
37 changes: 24 additions & 13 deletions API/youtubeAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,30 @@ var google = require('@googleapis/youtube');
var OAuth2 = google.auth.OAuth2;

async function youtubeAPI(tokens, resolveName, id, args) {
var oauth2Client = new OAuth2(
GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET
);

oauth2Client.setCredentials({
access_token: tokens.googleaccesstoken,
});

var youtube = google.youtube({
version: 'v3',
auth:oauth2Client
});

if (tokens.googleaccesstoken) {
const oauth2Client = new OAuth2(
GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET
);

oauth2Client.setCredentials({
access_token: tokens.googleaccesstoken,
});

youtube = google.youtube({
version: 'v3',
auth: oauth2Client
});
}
else if (tokens.googleapikey) {
youtube = google.youtube({
version: 'v3',
auth: tokens.googleapikey
});
} else {
throw new Error('No authentication method provided');
}

try {
const pages = args['pages'] - 1;
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Google API key as an alternative way to authorize [#179](https://github.com/ncsa/standalone-smm-smile/issues/179)

## [0.3.4] - 2024-06-27
### Added
- Randomly gather YouTube video using random search string [#169](https://github.com/ncsa/standalone-smm-smile/issues/169)
Expand Down

0 comments on commit 7f38a4e

Please sign in to comment.