1

In my Firefox OS privileged app I need authentication with Google.

uri=https://accounts.google.com/o/oauth2/auth............

var googleWin = window.open(uri, 'auth_window', 'fullscreen=0,width=200,height=100,resizable=1');


console.log(googleWin.document.title); 

The above statement which try to to print the document title result in error

Error: Permission denied to access property 'document'

I need to access the Google auth "code" from the document title.

How to solve the permission problem?

Thanks in advance.

Volker E.
  • 5,911
  • 11
  • 47
  • 64
anfas
  • 356
  • 2
  • 3
  • 13

2 Answers2

1

You can't directly access the components of the window. But you can write a javascript function inside the child auth_window that can easily access every dom element and perform any operations that you need or return back values. Then from your parent window, just make calls to these javascript functions:

console.log(googleWin.getDocumentTitle());
dreamerkumar
  • 1,540
  • 1
  • 18
  • 28
  • The window open page from google, So I cant add my custom function to that. Aso I tried to add a function to the child-window object returned by the open function. that too not working. – anfas Jul 03 '14 at 04:42
  • I didn't realize you actually do not own the child page. You can't add a function to that window. That function needs to be part of the content that is downloaded by that child frame. If you really want to achieve this, there is more work to do. Call the third party site using ajax. Create a new page on your own domain that builds up the page using that response. To this page you can add the required function. See Alex's answer below. He is probably implying the same. – dreamerkumar Jul 03 '14 at 18:43
1

Because of the same origin security policy, you're not going to be able to access that window's DOM. In the documentation, they suggest using AJAX with your auth code and processing the response of that request.

Alex W
  • 37,233
  • 13
  • 109
  • 109