0

I am making a simple web app and the service provider I am using authenticates through the OAuth 1.0 protocol. I would like to know how to extract a param after user signs in from a separate browser window and grants access. I have done this before in Objective-C for an iOS app using an event, but am unaware how to do it using a browser and using JavaScript. I assume I do something similar using an addEventListener() or onClick() type method? Also, can this quickly be achieved using a JQuery method? Details below.

I want to:

  1. Open a separate window to allow the user to sign in.

  2. User will then 'GRANT' access, at that point, the page will reload with the newly appended parameters to the URL.

  3. I then need to extract the params, which are the verifier and token oauth_verifier=verifier&oauth_token=token, from the URL after user signs in.

Something to note:
The service provider does not allow a callback. The user need to pass oauth_callback=oob for the param.

The link below is what I come across often while searching for an answer, however it just describes how to open a new window and point the user to a URL:

How to open a new window and insert html into it using jQuery?

Thank you for your help!

Community
  • 1
  • 1
Brian Mendez
  • 27
  • 1
  • 8

2 Answers2

1

If you open a new window with JavaScript, as described in the link you found, can you then access the location property to read the URL parameters?

var w = window.open(); console.log(w.location);

Maybe you need to check the value every 10 seconds with a setInterval or something, to get the new URL value once it updates after your user signs in.

Hope this helps!

brookr
  • 1,504
  • 12
  • 14
0
  1. Do not put any authentication information in the URL as it is not protected and can be intercepted.
  2. You can use localStorage to store authentication information and have that be available between different browser windows.
raduation
  • 792
  • 5
  • 11