Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add support for scope in request parameter to api.login.yahoo.com/oauth2/request_auth #117

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ node_modules
.esm-cache
.vs-code
dump.rdb
.vscode
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

13 changes: 9 additions & 4 deletions YahooFantasy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class YahooFantasy {
this.CONSUMER_SECRET = consumerSecret;
this.REDIRECT_URI = redirectUri;

this.refreshTokenCallback = () => {};
this.refreshTokenCallback = () => { };

if (tokenCallbackFn) {
this.refreshTokenCallback = tokenCallbackFn;
Expand Down Expand Up @@ -65,7 +65,7 @@ class YahooFantasy {
}

// oauth2 authenticatiocn function -- follow redirect to yahoo login
auth(res, state = null) {
auth(res, state = null, scope = null) {
const authData = {
client_id: this.CONSUMER_KEY,
redirect_uri: this.REDIRECT_URI,
Expand All @@ -76,6 +76,10 @@ class YahooFantasy {
authData.state = state;
}

if (scope) {
authData.scope = scope
}

const options = {
hostname: "api.login.yahoo.com",
port: 443,
Expand Down Expand Up @@ -140,9 +144,10 @@ class YahooFantasy {
});

tokenReponse.on("end", async () => {
const { access_token, refresh_token } = JSON.parse(
const data = JSON.parse(
Buffer.concat(chunks)
);
const { access_token, refresh_token } = data;

this.yahooUserToken = access_token;
this.yahooRefreshToken = refresh_token;
Expand All @@ -155,7 +160,7 @@ class YahooFantasy {
});
}

cb(null, { access_token, refresh_token, state });
cb(null, { ...data, state });
});
});

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global module, require */
require = require("esm")(module, true);
module.exports = require("./YahooFantasy.mjs").default;

module.exports.teamHelper = require('./helpers/teamHelper.mjs');
// TODO: league settings sample data
// TODO: transactions sample data
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.