Google-api-javascript-client: Authentication throws (b || "").split is not a function, dev key is not valid, popup_closed_by_user

Created on 28 Apr 2018  路  8Comments  路  Source: google/google-api-javascript-client

These 3 errors are preventing me from using the Google Drive API. You think this would have been tested? I am using the default Picker example code. Nothing changed but my client_id and my developer Key.

1) .split is not a function.

  • In firefox and chrome (did not check in IE or others), the resulting authentication throws a .split is not a function.
  • This happens randomly
  • Stack from chrome:
    3723580519-idpiframe.js:26 Uncaught TypeError: (b || "").split is not a function
    at Xa (3723580519-idpiframe.js:26)
    at 3723580519-idpiframe.js:61
    at 3723580519-idpiframe.js:55
    at eb.h.getItem (3723580519-idpiframe.js:35)
    at Ib.Q.o (3723580519-idpiframe.js:55)
    at Ib.o (3723580519-idpiframe.js:61)
    at Sb (3723580519-idpiframe.js:68)
    at W.h.kb (3723580519-idpiframe.js:76)
    at Object.A (3723580519-idpiframe.js:83)
    at Jb.Cb (3723580519-idpiframe.js:63)

2) API Developer Key is not valid (this is a repeat, I seen it posted many times)
The very first time I authenticate, the authentication works. But the next window displays "API Developer Key is not valid"
As mentioned here I removed the .setDeveloperKey(developerKey) and it then it random throws the ".split is not a function" error from above, or the popup_closed_by_user

3) If I do not get the "split is not a function error" I receive an error that the popup_closed_by_user

  • This is with or without the .setDeveloperKey(developerKey)
  • This is random. Sometimes it is the split, some times it is the popup_closed

The current state of the Picker is not usable.

Please advise.

Most helpful comment

I was having the (b || "").split is not a function error, and tracked down (what seems so far to be) a solution in this thread:
https://github.com/google/google-api-javascript-client/issues/13#issuecomment-290129284

GSI v2 does not accept a list of scope, it has to be a comma-delimited string (e.g. 'scope1 scope2'). > Change to 'https://www.googleapis.com/auth/drive' instead of ['https://www.googleapis.com/auth/drive'] and it will work.

Note that he means space-delimited. I was having this problem using the analytics API, and indeed, changing scope: ['https://www.googleapis.com/auth/analytics.readonly'] to scope: 'https://www.googleapis.com/auth/analytics.readonly' appears to have solved it.

All 8 comments

Having identical issues, albeit in a different order.

I was receiving API Developer Key is not valid first, and then I added the Google Identity scope, at which point I started receiving the (b || "").split is not a function error. Have not encountered the third error yet.

I'm developing in the current version of electron with ES6 and transpiling with Babel as well.

Any suggestions?

Edit: I'm not hitting all three cases. Seems completely random with the errors it's throwing out. I can change nothing and just reload and the error will change. Seems like the split error may have something to do with scopes though.

I figured it out for myself at least, make sure you have the "Google Picker API" API enabled and added to your API client

API library

I am still getting this error even though I have the "Google Picker API" API enabled. Any other ideas or suggestions?

@digitalbart What scopes are you requesting?

@XanderLuciano I am using Drive.scope for Google team drives. I think however my issue maybe more closely related to this one: https://github.com/google/google-api-javascript-client/issues/409 but I am not 100% sure they seem very similar.

I was having the (b || "").split is not a function error, and tracked down (what seems so far to be) a solution in this thread:
https://github.com/google/google-api-javascript-client/issues/13#issuecomment-290129284

GSI v2 does not accept a list of scope, it has to be a comma-delimited string (e.g. 'scope1 scope2'). > Change to 'https://www.googleapis.com/auth/drive' instead of ['https://www.googleapis.com/auth/drive'] and it will work.

Note that he means space-delimited. I was having this problem using the analytics API, and indeed, changing scope: ['https://www.googleapis.com/auth/analytics.readonly'] to scope: 'https://www.googleapis.com/auth/analytics.readonly' appears to have solved it.

The 'popup_closed_by_user' error should be fixed now. See: https://github.com/google/google-api-javascript-client/issues/405

@nvioli Thank You! That little subtlety saved the day.

Was this page helpful?
0 / 5 - 0 ratings