Instagram authentifacion failed

809 views
Skip to first unread message

Sergey Kostin

unread,
Aug 25, 2013, 2:02:45 PM8/25/13
to python-so...@googlegroups.com
First of all, thank you for developing this perfect module.

I almost finish my task, only one thing I could not to to authorize with Instagram authorized profile. I create an application in instagram, set to variables in settings but after clicking on Instagram Auth I see such error:

{"code": 400, "error_type": "OAuthException", "error_message": "Redirect URI does not match registered             redirect URI"}


Matías Aguirre

unread,
Aug 25, 2013, 2:56:06 PM8/25/13
to python-social-auth
Hi Sergey,

The error message says it all, check the value registered in Instagram for your
redirect URL and the one being sent by the app, some times something simple
like a trailing slash can trigger this error.

Matías

Excerpts from Sergey Kostin's message of 2013-08-25 15:02:45 -0300:
--
Matías Aguirre (matias...@gmail.com)

Sergey Kostin

unread,
Aug 26, 2013, 5:48:28 PM8/26/13
to python-so...@googlegroups.com

The error message says it all, check the value registered in Instagram for your
redirect URL and the one being sent by the app, some times something simple
like a trailing slash can trigger this error.

website : http://simpleboard.ru/
   http://simpleboard.ru/

I tried with slash and without in the end of url both seems to be not correct. 

Sergey Kostin

unread,
Aug 26, 2013, 5:54:37 PM8/26/13
to python-so...@googlegroups.com

Maybe I should add my redirect uri in some variable in settings?

Sergey Kostin

unread,
Aug 26, 2013, 6:16:55 PM8/26/13
to python-so...@googlegroups.com

I have a little progress, I changed my uri from / to /complete/instagram/ and it redirest me on instargam but after I autorize in instagram (i was not before) he redirect me to my site and I have such error now:

Authentication process canceled

/www/django/simpleboard/social/backends/oauth.py in auth_complete, line 319

Sergey Kostin

unread,
Sep 4, 2013, 2:00:25 PM9/4/13
to python-so...@googlegroups.com

Matías, please help me with this task. It seems that instagram sends everything what we need but python social app catch some situation and throw Error

 

Matías Aguirre

unread,
Sep 4, 2013, 2:31:09 PM9/4/13
to python-social-auth
Hi Sergey,

I've just tested instagram backend and it worked correctly. Since I'm testing
locally using the django example app which I'm running locally at
localhost:8000, I've set the application setting (on Instagram
http://instagram.com/developer/clients/manage/) to this values:

WEBSITE URL: http://localhost:8000/
REDIRECT URI: http://localhost:8000/complete/instagram/

Makes sense?
Matías

Excerpts from Sergey Kostin's message of 2013-09-04 15:00:25 -0300:
>
> Matías, please help me with this task. It seems that instagram sends
> everything what we need but python social app catch some situation and
> throw Error
>
--
Matías Aguirre (matias...@gmail.com)

Sergey Kostin

unread,
Sep 5, 2013, 4:00:20 AM9/5/13
to python-so...@googlegroups.com
I do exactly the same, but always catching Authentication process canceled  

AuthCanceled at /complete/instagram/


www/django/simpleboard/social/backends/oauth.py in auth_complete, line 321

Here is :

  1.                 self.ACCESS_TOKEN_URL,
  2.                 data=self.auth_complete_params(self.validate_state()),
  3.                 headers=self.auth_headers(),
  4.                 method=self.ACCESS_TOKEN_METHOD
  5.             )
  6.         except HTTPError as err:
  7.             if err.response.status_code == 400:
  1.                 raise AuthCanceled(self)
    ...
  1.             else:
  2.                 raise
  3.         except KeyError:
  4.             raise AuthUnknownError(self)
  5.         self.process_error(response)
  6.         return self.do_auth(response['access_token'], response=response,
response status code don"t valid

So I supposed something wrong in my settings. So I decided to show you all

# -*- coding: utf-8 -*-
import sys, site

site.addsitedir('/virtualenvs/simpleboard/lib/python3.2/site-packages')

from os.path import abspath, dirname, join


sys.path.insert(0, '../..')

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ROOT_PATH = abspath(dirname(__file__))

ADMINS = (
    # ('Your Name', 'your_...@socialauth.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/www/db/board.db'
    }
}

TIME_ZONE = 'Europe/Moscow'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
MEDIA_ROOT = ''
MEDIA_URL = ''

STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

SECRET_KEY = '#$5btppqih8=%ae^#&7en#kyi!vh%he9rg=ed#hm6fnw9^=umc'

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'simpleboard.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'simpleboard.wsgi.application'

TEMPLATE_DIRS = (
    join(ROOT_PATH, 'templates'),
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    #'south',
    # 'raven.contrib.django.raven_compat',
    'social.apps.django_app.default',
    'socialauth',
    'emailconfirmation',
    'account'
)

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.contrib.messages.context_processors.messages',
    'social.apps.django_app.context_processors.backends',
)

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'social.backends.twitter.TwitterOAuth',
    'social.backends.facebook.FacebookOAuth2',
    'social.backends.instagram.InstagramOAuth2',
    'social.backends.vk.VKOAuth2',

)

AUTH_PROFILE_MODULE = 'account.UserProfile'

SESSION_ENGINE = 'django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_SAVE_EVERY_REQUEST = True
SESSION_COOKIE_AGE = 86400 # sec
SESSION_COOKIE_DOMAIN = None
SESSION_COOKIE_NAME = 'DSESSIONID'
SESSION_COOKIE_SECURE = False


LOGIN_URL = '/'
LOGIN_REDIRECT_URL = '/done/'
URL_PATH = ''
SOCIAL_AUTH_STRATEGY = 'social.strategies.django_strategy.DjangoStrategy'
SOCIAL_AUTH_STORAGE = 'social.apps.django_app.default.models.DjangoStorage'
SOCIAL_AUTH_GOOGLE_OAUTH_EXTRA_SCOPE = [
    'https://www.googleapis.com/auth/drive',
    'https://www.googleapis.com/auth/userinfo.profile'
]

SOCIAL_AUTH_VK_OAUTH2_KEY = '3284197'
SOCIAL_AUTH_VK_OAUTH2_SECRET = 'b4t2yOzVqsSlDrIzNp35'

SOCIAL_AUTH_FACEBOOK_KEY = '514826991930448'
SOCIAL_AUTH_FACEBOOK_SECRET = '168594f45e3236b534b6122b59e2e386'

SOCIAL_AUTH_TWITTER_KEY = '3dZH6BHUUTf1rJMXxWSrKw'
SOCIAL_AUTH_TWITTER_SECRET = 'chbscRS1PUMTdq1yWDXHEKwPOLBGDj2hDrzVBU7tA8'

SOCIAL_AUTH_INSTAGRAM_KEY = '4d50a8dccca541efb3ae267dc1fe9428'
SOCIAL_AUTH_INSTAGRAM_SECRET = '98db72492dcf44148f6a0f4a2145bed8'

EMAIL_CONFIRMATION_DAYS = 2
DEFAULT_FROM_EMAIL = "nor...@simpleboard.ru"



среда, 4 сентября 2013 г., 22:31:09 UTC+4 пользователь Matías Aguirre написал:Hi Sergey,

Yogita Chouhan

unread,
Dec 15, 2015, 1:01:51 AM12/15/15
to python-social-auth

Hello, 
    I want to connect my project to instagram and for this task when i click on instagram its open login page and after login its give such type of error 
    

  HTTPError at /complete/instagram/

 405 Client Error: METHOD NOT ALLOWED

 Please help me to solve this error and i attached screenshot of instagram error
instagram.png

Matías Aguirre

unread,
Dec 15, 2015, 1:18:23 AM12/15/15
to Yogita Chouhan, python-social-auth
Please provide the full traceback.
--
Matías Aguirre
http://matiasaguirre.net

Raji Chithiraipandian

unread,
Dec 30, 2015, 6:32:17 AM12/30/15
to python-social-auth, yogitayu...@gmail.com
Hi,

I am also facing the same error - 405 Client Error: METHOD NOT ALLOWED. Please help us to solve this issue. My traceback is
Environment:


Request Method: GET

Django Version: 1.6.2
Python Version: 2.7.5
Installed Applications:
('webui',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sites',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'portals',
 'south',
 'storages',
 'django_countries',
 'captcha',
 'pagination',
 'carton',
 'paypal.standard.pdt',
 'billing',
 'sorl.thumbnail',
 'haystack',
 'django_sorting',
 'django_sortable',
 'file_resubmit',
 'corsheaders',
 'social.apps.django_app.default')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'pagination.middleware.PaginationMiddleware',
 'django_sorting.middleware.SortingMiddleware',
 'audit_log.middleware.UserLoggingMiddleware')


Traceback:
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  114.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/rajeshwari/Documents/code/bespoke/src/bespoke_webui/portals/views.py" in complete_wrapper
  1866.         return complete(request, backend)
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
  57.         return view_func(*args, **kwargs)
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/social/apps/django_app/utils.py" in wrapper
  51.             return func(request, backend, *args, **kwargs)
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/social/apps/django_app/views.py" in complete
  28.                        redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/social/actions.py" in do_complete
  43.         user = backend.complete(user=user, *args, **kwargs)
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/social/backends/base.py" in complete
  41.         return self.auth_complete(*args, **kwargs)
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/social/utils.py" in wrapper
  229.             return func(*args, **kwargs)
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/social/backends/oauth.py" in auth_complete
  383.             method=self.ACCESS_TOKEN_METHOD
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/social/backends/oauth.py" in request_access_token
  361.         return self.get_json(*args, **kwargs)
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/social/backends/base.py" in get_json
  229.         return self.request(url, *args, **kwargs).json()
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/social/backends/base.py" in request
  225.         response.raise_for_status()
File "/home/rajeshwari/Envs/bespoke/local/lib/python2.7/site-packages/requests/models.py" in raise_for_status
  840.             raise HTTPError(http_error_msg, response=self)

Exception Type: HTTPError at /complete/instagram/
Exception Value: 405 Client Error: METHOD NOT ALLOWED for url: https://www.instagram.com/oauth/access_token
Reply all
Reply to author
Forward
0 new messages