diff --git a/demos/yahoo.html b/demos/yahoo.html
index 879db3df..2e2b0a9d 100644
--- a/demos/yahoo.html
+++ b/demos/yahoo.html
@@ -15,25 +15,26 @@
hello( yahoo )
+
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 9f11b8f7..936746c3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "hellojs",
- "version": "1.19.5",
+ "version": "1.20.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "hellojs",
- "version": "1.19.5",
+ "version": "1.20.0",
"license": "MIT",
"devDependencies": {
"@semantic-release/changelog": "^6.0.2",
diff --git a/src/modules/yahoo.js b/src/modules/yahoo.js
index a70b1803..7dcf26dc 100644
--- a/src/modules/yahoo.js
+++ b/src/modules/yahoo.js
@@ -1,160 +1,51 @@
(function(hello) {
- hello.init({
-
- yahoo: {
-
- // Ensure that you define an oauth_proxy
- oauth: {
- version: '1.0a',
- auth: 'https://api.login.yahoo.com/oauth/v2/request_auth',
- request: 'https://api.login.yahoo.com/oauth/v2/get_request_token',
- token: 'https://api.login.yahoo.com/oauth/v2/get_token',
- // Yahoo requires the state param to be base 64 encoded, hence the flag base64_state is set to true for Yahoo.
- // Else uri encoding is used for all the other providers.
- base64_state: true
- },
-
- // Login handler
- login: function(p) {
- // Change the default popup window to be at least 560
- // Yahoo does dynamically change it on the fly for the signin screen (only, what if your already signed in)
- p.options.popup.width = 560;
-
- // Yahoo throws an parameter error if for whatever reason the state.scope contains a comma, so lets remove scope
- try {delete p.qs.state.scope;}
- catch (e) {}
- },
-
- base: 'https://social.yahooapis.com/v1/',
-
- get: {
- me: yql('select * from social.profile(0) where guid=me'),
- 'me/friends': yql('select * from social.contacts(0) where guid=me'),
- 'me/following': yql('select * from social.contacts(0) where guid=me')
- },
- wrap: {
- me: formatUser,
-
- // Can't get IDs
- // It might be better to loop through the social.relationship table with has unique IDs of users.
- 'me/friends': formatFriends,
- 'me/following': formatFriends,
- 'default': paging
- }
- }
- });
-
- /*
- // Auto-refresh fix: bug in Yahoo can't get this to work with node-oauth-shim
- login : function(o){
- // Is the user already logged in
- var auth = hello('yahoo').getAuthResponse();
-
- // Is this a refresh token?
- if(o.options.display==='none'&&auth&&auth.access_token&&auth.refresh_token){
- // Add the old token and the refresh token, including path to the query
- // See http://developer.yahoo.com/oauth/guide/oauth-refreshaccesstoken.html
- o.qs.access_token = auth.access_token;
- o.qs.refresh_token = auth.refresh_token;
- o.qs.token_url = 'https://api.login.yahoo.com/oauth/v2/get_token';
- }
- },
- */
-
- function formatError(o) {
- if (o && 'meta' in o && 'error_type' in o.meta) {
- o.error = {
- code: o.meta.error_type,
- message: o.meta.error_message
- };
- }
- }
-
- function formatUser(o) {
-
- formatError(o);
- if (o.query && o.query.results && o.query.results.profile) {
- o = o.query.results.profile;
- o.id = o.guid;
- o.last_name = o.familyName;
- o.first_name = o.givenName || o.nickname;
- var a = [];
- if (o.first_name) {
- a.push(o.first_name);
- }
-
- if (o.last_name) {
- a.push(o.last_name);
- }
-
- o.name = a.join(' ');
- o.email = (o.emails && o.emails[0]) ? o.emails[0].handle : null;
- o.thumbnail = o.image ? o.image.imageUrl : null;
- }
-
- return o;
- }
-
- function formatFriends(o, headers, request) {
- formatError(o);
- paging(o, headers, request);
- var contact;
- var field;
- if (o.query && o.query.results && o.query.results.contact) {
- o.data = o.query.results.contact;
- delete o.query;
-
- if (!Array.isArray(o.data)) {
- o.data = [o.data];
- }
-
- o.data.forEach(formatFriend);
- }
-
- return o;
- }
-
- function formatFriend(contact) {
- contact.id = null;
-
- // #362: Reports of responses returning a single item, rather than an Array of items.
- // Format the contact.fields to be an array.
- if (contact.fields && !(contact.fields instanceof Array)) {
- contact.fields = [contact.fields];
- }
-
- (contact.fields || []).forEach(function(field) {
- if (field.type === 'email') {
- contact.email = field.value;
- }
-
- if (field.type === 'name') {
- contact.first_name = field.value.givenName;
- contact.last_name = field.value.familyName;
- contact.name = field.value.givenName + ' ' + field.value.familyName;
- }
-
- if (field.type === 'yahooid') {
- contact.id = field.value;
- }
- });
- }
-
- function paging(res, headers, request) {
-
- // See: http://developer.yahoo.com/yql/guide/paging.html#local_limits
- if (res.query && res.query.count && request.options) {
- res.paging = {
- next: '?start=' + (res.query.count + (+request.options.start || 1))
- };
- }
-
- return res;
- }
-
- function yql(q) {
- return 'https://query.yahooapis.com/v1/yql?q=' + (q + ' limit @{limit|100} offset @{start|0}').replace(/\s/g, '%20') + '&format=json';
- }
-
-})(hello);
+ hello.init({
+ yahoo: {
+ // Updated to modern OAuth 2.0 authentication flow
+ oauth: {
+ version: 2,
+ auth: 'https://api.login.yahoo.com/oauth2/request_auth',
+ grant: 'https://api.login.yahoo.com/oauth2/get_token'
+ },
+
+ // Modern Yahoo API requires a different scope format
+ scope: {
+ basic: 'openid profile email'
+ },
+
+ // The `base` URL now points to the new user info endpoint.
+ base: 'https://api.login.yahoo.com/openid/v1/userinfo',
+
+ // Login handler
+ login: function(p) {
+ // Yahoo requires the state param to be base 64 encoded.
+ p.qs.base64_state = true;
+ },
+
+ // API methods to get user data
+ get: {
+ me: 'https://api.login.yahoo.com/openid/v1/userinfo'
+ },
+
+ // Wrapper to handle the new data format from the `userinfo` endpoint
+ wrap: {
+ me: formatUser
+ }
+ }
+ });
+
+ // Helper function to format user data
+ function formatUser(o) {
+ if (o.sub) {
+ o.id = o.sub;
+ o.name = o.name;
+ o.first_name = o.given_name;
+ o.last_name = o.family_name;
+ o.email = o.email;
+ o.thumbnail = o.picture;
+ }
+ return o;
+ }
+
+})(hello);
\ No newline at end of file