0

I'm trying to implements the basic JavaScript Code Samples inside an Electron app. I've successfully created my project and added an API key credentials in the Google Console.

However, when I try the basic samples into an Electron app, I get the following error:

Refused to display 'https://accounts.google.com/o/oauth2/auth?client_id=...' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

What should I do to avoid that?

Yann Bertrand
  • 3,084
  • 1
  • 22
  • 38

1 Answers1

0

Sometimes the Client ID can be the issue. See Here

You can also use CORS if that does not work:

https://developers.google.com/api-client-library/javascript/features/cors

Community
  • 1
  • 1
Eric Kelly
  • 435
  • 3
  • 8
  • I'm already using a "Web Client" Client ID. With the CORS solution, I get a 403 with the first example, and I can't get an access token cause calling `authorize` fail for the same reason as the question. – Yann Bertrand Dec 01 '15 at 20:57
  • I set up a [web project](https://github.com/YannBertrand/YoutubeApiExample) and get exactly the same issue. – Yann Bertrand Dec 03 '15 at 20:43
  • [Found it](http://stackoverflow.com/questions/24681594/google-api-400-bad-request-and-refused-to-display-in-a-frame-because-i) – Yann Bertrand Dec 03 '15 at 21:16
  • 1
    should always use private browsing mode when testing and disable cache in dev tools. – Eric Kelly Dec 04 '15 at 01:42
  • Have you got an idea on how to do that inside an Electron app? – Yann Bertrand Dec 04 '15 at 10:50
  • use browser-window.webPreferences.partition option to isolate session/cookies or make it in-memory so it isn't stored. – Eric Kelly Dec 04 '15 at 17:16
  • I've set the browser window `webPreferences.partition` to `''`, `'test'` and `'persist:test'`, none of these values resolve the problem... What do you mean by "make it in-memory"? – Yann Bertrand Dec 04 '15 at 22:59
  • look at the electron doc. depends what version too possibly. – Eric Kelly Dec 05 '15 at 01:53
  • I can't find it... I guess it's only possible by doing this [server-side](http://iamemmanouil.com/blog/electron-oauth-with-github/) – Yann Bertrand Dec 10 '15 at 19:45