yakyak / hangupsjs

google hangouts client library for nodejs
226 stars 46 forks source link

Not authorized to request the scopes #70

Open synle opened 7 years ago

synle commented 7 years ago

I got this error trying to set up the oauth

400. That’s an error.

Error: invalid_scope

Not authorized to request the scopes: [https://www.google.com/accounts/OAuthLogin]

Learn more

Request Details
That’s all we know.

2017-04-11 07_43_49-error 400 oauth2 error 1

averissimo commented 7 years ago

We have updated this in the YakYak app some time ago, but not in hangupsjs itself :\

I'm not really sure on this.. @davibe ?

My workaround is to start a session with YakYak and then copy Cookies, cookies.json and refreshtoken.txt to hangupsjs folder

dosmage commented 7 years ago

@averissimo hello! I'm kind of new to node.js and OAuth. I can't seem to get the constructors to be happy setting it to read from the CookieJar. May I ask if you don't mind sharing your code that let's you read the files from YakYak? I would greatly appreciate it!

averissimo commented 7 years ago

@dosmage

https://github.com/averissimo/hangupsjs/tree/my_blank_login

I use this code to test some stuff, see src/login.coffee..

To get the right scope files:

ps. I use some stuff inside login to send 'Hello World' messages to specific conversations and check for user presence (all depending on the login user)... you can use that code as inspiration

MTRNord commented 7 years ago

Hi you said it is fixed in yakyak? Where do you the login in YakYak?

Makhlab commented 7 years ago

Got same error. What else scopes we can try? I tried https://www.googleapis.com/auth/plus.login scope... the response

2017-07-22 12:05:42 DEBUG requesting refresh token 2017-07-22 12:05:42 DEBUG auth with code success 2017-07-22 12:05:42 DEBUG attempt to get session cookies ya29.GmCQBIm5oHiERSQPIj3-TRttWGEh07yKamTZZGoZKlkbEDjGhCtW4fxuXXL_15ZqxKCUECIBtf9Pn0jlU05zVCczUC4UV9U1e0cJiaTjivrU3ftnIOTrnHWWz8hIMwExb0k 2017-07-22 12:05:42 DEBUG requesting uberauth 2017-07-22 12:05:43 ERROR getAuth failed { [Error: Forbidden] code: 403, message: 'Forbidden', body: 'Error=badauth\n' } 2017-07-22 12:05:43 DEBUG emit connect_failed { [Error: Forbidden] code: 403, message: 'Forbidden', body: 'Error=badauth\n' }

/Users/max/projects/js/node_modules/q/q.js:155 throw e; ^ Error: Forbidden

It is because of the wrong scope?

averissimo commented 7 years ago

Check this: https://productforums.google.com/forum/#!topic/hangouts/LU2YZNDhN_s

The necessary authentication endpoint must be changed to programmatic_auth, the caveat is that the code does not appear directly in the page, it must be retrieved by inpector :\

I've just tested the code below, it should work using the workaround described in the link/video

https://github.com/yakyak/yakyak/blob/master/src/login.coffee#L7

OAUTH2_CLIENT_ID     = '936475272427.apps.googleusercontent.com'
OAUTH2_CLIENT_SECRET = 'KWsJlkaMn1jGLxQpWxMnOox-'

OAUTH2_SCOPE         = 'https://www.google.com/accounts/OAuthLogin https://www.googleapis.com/auth/userinfo.email'

OAUTH2_DELEGATED_CLIENT_ID = '183697946088-m3jnlsqshjhh5lbvg05k46q1k4qqtrgn.apps.googleusercontent.com'

OAUTH2_PARAMS =
    hl: 'en'
    scope: OAUTH2_SCOPE
    client_id:    OAUTH2_CLIENT_ID
    access_type: 'offline'
    delegated_client_id: OAUTH2_DELEGATED_CLIENT_ID
    top_level_cookie: '1'

OAUTH2_QUERY = ("&#{k}=#{encodeURIComponent(v)}" for k, v of OAUTH2_PARAMS).join('')
OAUTH2_LOGIN_URL = "https://accounts.google.com/o/oauth2/programmatic_auth?#{OAUTH2_QUERY}"
OAUTH2_TOKEN_REQUEST_URL = 'https://accounts.google.com/o/oauth2/token'
averissimo commented 7 years ago

or see branch scope_workaround for a working example

lorenzos commented 6 years ago

@averissimo Branch scope_workaround does not work for me. I see the URL with "programmatic_auth" instead of "auth", but when opened it asks my password and then hangs indefinitely with "One moment please..."

lorddrak commented 4 years ago

Got same error. What else scopes we can try? I tried https://www.googleapis.com/auth/plus.login scope... the response

2017-07-22 12:05:42 DEBUG requesting refresh token 2017-07-22 12:05:42 DEBUG auth with code success 2017-07-22 12:05:42 DEBUG attempt to get session cookies ya29.GmCQBIm5oHiERSQPIj3-TRttWGEh07yKamTZZGoZKlkbEDjGhCtW4fxuXXL_15ZqxKCUECIBtf9Pn0jlU05zVCczUC4UV9U1e0cJiaTjivrU3ftnIOTrnHWWz8hIMwExb0k 2017-07-22 12:05:42 DEBUG requesting uberauth 2017-07-22 12:05:43 ERROR getAuth failed { [Error: Forbidden] code: 403, message: 'Forbidden', body: 'Error=badauth\n' } 2017-07-22 12:05:43 DEBUG emit connect_failed { [Error: Forbidden] code: 403, message: 'Forbidden', body: 'Error=badauth\n' } /Users/max/projects/js/node_modules/q/q.js:155 throw e; ^ Error: Forbidden

It is because of the wrong scope?

Any information about this? I'm facing this since couple of days and can't find any information.

averissimo commented 4 years ago

Are you using version 1.5.7 or above?

Undrium commented 4 years ago

I'm using 1.3.8 and getting this:

2020-06-21 22:30:00 WARN no init data for apikey 2020-06-21 22:30:00 WARN no init data for email 2020-06-21 22:30:00 WARN no init data for headerdate 2020-06-21 22:30:00 WARN no init data for headerversion 2020-06-21 22:30:00 WARN no init data for headerid 2020-06-21 22:30:00 WARN no init data for timestamp 2020-06-21 22:30:00 WARN no init data for self_entity 2020-06-21 22:30:00 WARN no init data for conv_states { "error": { "errors": [ { "domain": "usageLimits", "reason": "dailyLimitExceededUnreg", "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.", "extendedHelp": "https://code.google.com/apis/console" } ], "code": 403, "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup." } }

I'm using the token mentioned earlier, not sure what has changed. Updating it won't do the trick.

lorddrak commented 4 years ago

I'm using lastest version of git "npm install https://github.com/yakyak/hangupsjs.git" after that I needed to auth again and everything works again

averissimo commented 4 years ago

@Undrium sorry, I thought I was in the yakyak app context. You can use the code from github, but I'll ask the person with npm permissions to bump the new version.

@davibe can you push a new version (1.3.9) to npm ?