OAuth (Instagram) without refresh

我是研究僧i 提交于 2019-12-20 12:38:14

问题


I have a single page javascript application, and I'm wondering if I can authenticate the user on Instagram without refreshing the page. I'd like to try to do something similar to the Facebook connect using javascript, where a Facebook dialog opens in a popup then calls a callback script after.

Here's what I'm thinking it would do...

  1. On click, opens a dialog (popup) window where the user logs in to Instagram and the app is granted permission.
  2. In the popup window, the user is redirected back to my website where my website curls to Instagram to get the access_token, then sets the access token in the user's session or as a cookie.
  3. Somehow...the main application needs to recognize when the access token has been set. This is the point I'm really not sure about. Would I use a timer to keep making calls back to the server to check for it? Does anyone have any better ideas for detecting it? Would it work better to set it in a cookie?

I thought I'd ask here first before I start coding incase anyone had any ideas as to if this would/wouldn't work, or other suggestions! Maybe this already exists and I'm missing something?

Thanks in advance :-)


回答1:


It ended up being super easy to do this with a popup using the comments from tdun and Jan. Thanks guys! Used the Instgram class from 9lessons, and used window.opener.processAuthData(authData) to call back to the original window. And I did have to do a refresh, but it was in the popup window, not in the main app window, which was what I was going for.



来源:https://stackoverflow.com/questions/12397433/oauth-instagram-without-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!