whatadewitt / yahoo-fantasy-sports-api

NodeJS wrapper for the Yahoo! Fantasy Sports API
https://yahoo-fantasy-node-docs.vercel.app/
MIT License
192 stars 52 forks source link

Setup module with Angular #23

Closed isaacrlevin closed 6 years ago

isaacrlevin commented 7 years ago

I wanted to add your module to a .Net App that I wrote (it currently works with oauth.io for auth, which sucks) but just the OAuth piece as that seems to be the pain point with this whole thing. I tried to add your module to my app, but I am getting some requirejs errors. Is there an easy fix for this?

whatadewitt commented 7 years ago

Wow... front end... I hadn't even thought about that implementation yet...

The short answer is no, I don't know what the easy fix would be. I've been focused on a lot of projects at work lately and my move to OAuth2 has certainly been stalled by that. I'm thinking that MIGHT help solve some of the issues, but I really haven't put any thought into how this should/would work on the front end, so quickly thinking about it, it may be a tougher task than just dropping it in...

isaacrlevin commented 7 years ago

Sure, I was able to use browserify to get the node module into my app, so I got past that. Quick question, how do you fire the oauth piece? What method calls brings up the yahoo page with the callback?

isaacrlevin commented 7 years ago

I think I figured it out, I don't need this module, I need the passport one. Looking into that now

whatadewitt commented 7 years ago

Hey have you made any progress here? Will passport even work client side? I'm working on moving the Oauth piece out of this and using Oauth 2, which may actually solve the problem. I'm very interested to know about how this is going to work.

isaacrlevin commented 7 years ago

I honestly stopped looking at it. I got really annoyed at how uneasy it was to interface with the damn thing. I might look back into it with something like satellizer https://github.com/sahat/satellizer but I don't know. Are you planning on changing the passport piece to OAuth 2.0?

Isaac

On Sun, Oct 23, 2016 at 9:00 PM, Luke DeWitt notifications@github.com wrote:

Hey have you made any progress here? Will passport even work client side? I'm working on moving the Oauth piece out of this and using Oauth 2, which may actually solve the problem. I'm very interested to know about how this is going to work.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/whatadewitt/yfsapi/issues/23#issuecomment-255627602, or mute the thread https://github.com/notifications/unsubscribe-auth/AId5piCUgR5PsLdwz0SB_P_CMh9b3C2rks5q3AM3gaJpZM4KaQQk .

whatadewitt commented 7 years ago

I'll probably be removing that piece totally. The user should be generating the Auth token outside of my lib and then just passing it in once they've created it, which should help with what you're trying to achieve.

isaacrlevin commented 7 years ago

Aw man I actually am in the same boat. All my core code is in C# Web Api. I just need a token to get started as well. I currently am using some 3rd party to get that to work and am not a fan. There has to be something out there that works with this shitty oauth 1.0 implementation

On Wed, Oct 26, 2016 at 9:08 AM -0400, "Luke DeWitt" notifications@github.com wrote:

I'll probably be removing that piece totally. The user should be generating the Auth token outside of my lib and then just passing it in once they've created it, which should help with what you're trying to acheive.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

whatadewitt commented 7 years ago

I have an OAuth2 release coming soon which SHOULD help with a lot of this... does your JS exist anywhere on Github? I would love to add a "Front End Integration" example to my sandbox app...

isaacrlevin commented 7 years ago

No but i can give it to you. Its wored up to hit a WebApi for everything, but i can try to extract the auth sruff this weekend

Isaac

On Sat, Nov 5, 2016 at 9:02 PM -0400, "Luke DeWitt" notifications@github.com wrote:

I have an OAuth2 release coming soon which SHOULD help with a lot of this... does your JS exist anywhere on Github? I would love to add a "Front End Integration" example to my sandbox app...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

isaacrlevin commented 7 years ago

Lile i said, i am using oauth.io currently to handle all the initial auth and I get back access tokens which i put in the header. Here is the whoke code. Let me knownif you jeed anything else.

function initialize() {

            //initialize OAuth.io with public key of the application

            OAuth.initialize('wj806rj-GeuMEcjtlrsv5kuYm0k', { cache: true });

            authorizationResult = OAuth.create('yahoo');

        }

        function isReady() {

            return (authorizationResult);

        }

        function connectYahoo() {

            var deferred = $q.defer();

            OAuth.popup('yahoo', { cache: true }, function (error, result) { //cache means to execute the callback if the tokens are already present

                if (!error) {

                    authorizationResult = result;

                    deferred.resolve();

                } else {

                    var foo = "";

                }

            });

            return deferred.promise;

        }

        function clearCache() {

            OAuth.clearCache('yahoo');

            authorizationResult = false;

        }

        function getLeaguesList() {

            //create a deferred object using Angular's $q service

            var deferred = $q.defer();

            $http.get(url + "api/home/ListLeagues",

                                     {

                                         headers:

                                          {

                                              'Access-Key': authorizationResult.oauth_token,

                                              'Access-Secret': authorizationResult.oauth_token_secret

                                          }

                                     }).success(function (data) {

                                         deferred.resolve(data)

                                     });

            return deferred.promise;

        }

On Sat, Nov 5, 2016 at 9:02 PM -0400, "Luke DeWitt" notifications@github.com wrote:

I have an OAuth2 release coming soon which SHOULD help with a lot of this... does your JS exist anywhere on Github? I would love to add a "Front End Integration" example to my sandbox app...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.