norm / instagram-backup

Fetch a copy of your photos and metadata from Instagram
13 stars 2 forks source link

OAuth2AuthExchangeError: Client ID doesn't match original request #2

Open quinncnl opened 8 years ago

quinncnl commented 8 years ago

Hello,

I encountered this problem with the following traces:

127.0.0.1 - - [10/Jan/2016 11:16:19] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2016 11:16:26] "GET /?code=b689e0dc8edb476ea1f5668bac3a5a31 HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/clear/Dropbox/dev/instagram-backup-master/get_token.py", line 33, in homepage
    instagram.exchange_code_for_access_token(code)
  File "/Library/Python/2.7/site-packages/instagram/oauth2.py", line 48, in exchange_code_for_access_token
    return req.exchange_for_access_token(code=code)
  File "/Library/Python/2.7/site-packages/instagram/oauth2.py", line 115, in exchange_for_access_token
    raise OAuth2AuthExchangeError(parsed_content.get("error_message", ""))
OAuth2AuthExchangeError: Client ID doesn't match original request

Any ideas on how to fix it?

max-arnold commented 8 years ago

The code contains hardcoded Client ID. You can apply the following patch:

diff --git a/get_token.py b/get_token.py
index aa4626a..024e024 100644
--- a/get_token.py
+++ b/get_token.py
@@ -27,7 +27,7 @@ def homepage():
     code = request.args.get('code', None)

     if code is None:
-        return render_template('homepage.html')
+        return render_template('homepage.html', client_id=ID)
     else:
         token, user_data = \
             instagram.exchange_code_for_access_token(code)
diff --git a/templates/homepage.html b/templates/homepage.html
index 817a21c..76dff14 100644
--- a/templates/homepage.html
+++ b/templates/homepage.html
@@ -1,5 +1,5 @@
 {% extends "base.html" %}

 {% block body %}
-  <a href='https://instagram.com/oauth/authorize/?client_id=749fd37ef1314c69ba2c65711acd8f2c&amp;redirect_uri=http://localhost:4726/&amp;response_type=code'>click to get auth token</a>
+  <a href='https://instagram.com/oauth/authorize/?client_id={{ client_id }}&amp;redirect_uri=http://localhost:4726/&amp;response_type=code'>click to get auth token</a>
 {% endblock %}