New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

401 error on everything, but I can authenticate fine. #133

Closed
asharma567 opened this Issue Jan 24, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@asharma567

asharma567 commented Jan 24, 2017

I can authenticate just fine but if I try to match, get nearby users or anything else I get a 401. I've also tried just authenticating using X-Auth as well and it didn't work. Please let me know.

I get the app id, secret code by making new app of facebook sdk page.

session = pynder.Session(facebook_id, facebook_auth_token)

session.profile
Traceback (most recent call last):
File "", line 1, in
File "/Users/ajay/anaconda/lib/python2.7/site-packages/cached_property-1.3.0-py2.7.egg/cac
value = obj.dict[self.func.name] = self.func(obj)
File "pynder/session.py", line 22, in profile
return Profile(self._api.profile(), self._api)
File "pynder/api.py", line 68, in profile
return self._get("/profile")
File "pynder/api.py", line 47, in _get
return self._request("get", url)
File "pynder/api.py", line 41, in _request
raise errors.RequestError(result.status_code)
pynder.errors.RequestError: 401

@olivierapex

This comment has been minimized.

Show comment
Hide comment
@olivierapex

olivierapex Jan 29, 2017

Same issue here ...

olivierapex commented Jan 29, 2017

Same issue here ...

@PaulAhuevo

This comment has been minimized.

Show comment
Hide comment
@PaulAhuevo

PaulAhuevo Feb 4, 2017

I could resolve the issue by removing the facebook_id. It seems like it is not needed anymore.
So just try: session = pynder.Session(facebook_auth_token)

PaulAhuevo commented Feb 4, 2017

I could resolve the issue by removing the facebook_id. It seems like it is not needed anymore.
So just try: session = pynder.Session(facebook_auth_token)

@asharma567

This comment has been minimized.

Show comment
Hide comment
@asharma567

asharma567 Feb 10, 2017

#114 (comment)
Looking at this post resolved it. I wasn't pulling the right auth token yet I was still able to get past the authentication stage.

#below gets me the wrong token...
def get_app_access_token(app_id, app_secret):
"""
Get the access_token for the app.

This token can be used for insights and creating test users.

@arg app_id :type string :desc retrieved from the developer page
@arg app_secret :type string :desc retrieved from the developer page

Returns the application access_token.

"""
import urllib2
import urllib
# Get an app access token
args = {
    'grant_type': 'client_credentials',
    'client_id': app_id,
    'client_secret': app_secret
}

f = urllib2.urlopen("https://graph.facebook.com/oauth/access_token?" +
                          urllib.urlencode(args))

try:
    result = f.read().split("=")[1].split('|')

#it's always executed just before leaving the try. 
#meaning it could raise an exception and it'll still get executud
#here it means a garuantee close to the file.
finally:
    f.close()

if len(result) > 1:
    return result[1]
return result

#below gets me the right token

import re
import robobrowser

MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; en-gb; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.16 Safari/535.19"
FB_AUTH = "https://www.facebook.com/v2.6/dialog/oauth?redirect_uri=fb464891386855067%3A%2F%2Fauthorize%2F&display=touch&state=%7B%22challenge%22%3A%22IUUkEUqIGud332lfu%252BMJhxL4Wlc%253D%22%2C%220_auth_logger_id%22%3A%2230F06532-A1B9-4B10-BB28-B29956C71AB1%22%2C%22com.facebook.sdk_client_state%22%3Atrue%2C%223_method%22%3A%22sfvc_auth%22%7D&scope=user_birthday%2Cuser_photos%2Cuser_education_history%2Cemail%2Cuser_relationship_details%2Cuser_friends%2Cuser_work_history%2Cuser_likes&response_type=token%2Csigned_request&default_audience=friends&return_scopes=true&auth_type=rerequest&client_id=464891386855067&ret=login&sdk=ios&logger_id=30F06532-A1B9-4B10-BB28-B29956C71AB1&ext=1470840777&hash=AeZqkIcf-NEW6vBd"

def get_access_token(email, password):
s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml")
s.open(FB_AUTH)
##submit login form##
f = s.get_form()
f["pass"] = password
f["email"] = email
s.submit_form(f)
##click the 'ok' button on the dialog informing you that you have already authenticated with the Tinder app##
f = s.get_form()
s.submit_form(f, submit=f.submit_fields['CONFIRM'])
##get access token from the html response##
access_token = re.search(r"access_token=([\w\d]+)", s.response.content.decode()).groups()[0]
#print s.response.content.decode()
return access_token

asharma567 commented Feb 10, 2017

#114 (comment)
Looking at this post resolved it. I wasn't pulling the right auth token yet I was still able to get past the authentication stage.

#below gets me the wrong token...
def get_app_access_token(app_id, app_secret):
"""
Get the access_token for the app.

This token can be used for insights and creating test users.

@arg app_id :type string :desc retrieved from the developer page
@arg app_secret :type string :desc retrieved from the developer page

Returns the application access_token.

"""
import urllib2
import urllib
# Get an app access token
args = {
    'grant_type': 'client_credentials',
    'client_id': app_id,
    'client_secret': app_secret
}

f = urllib2.urlopen("https://graph.facebook.com/oauth/access_token?" +
                          urllib.urlencode(args))

try:
    result = f.read().split("=")[1].split('|')

#it's always executed just before leaving the try. 
#meaning it could raise an exception and it'll still get executud
#here it means a garuantee close to the file.
finally:
    f.close()

if len(result) > 1:
    return result[1]
return result

#below gets me the right token

import re
import robobrowser

MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; en-gb; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.16 Safari/535.19"
FB_AUTH = "https://www.facebook.com/v2.6/dialog/oauth?redirect_uri=fb464891386855067%3A%2F%2Fauthorize%2F&display=touch&state=%7B%22challenge%22%3A%22IUUkEUqIGud332lfu%252BMJhxL4Wlc%253D%22%2C%220_auth_logger_id%22%3A%2230F06532-A1B9-4B10-BB28-B29956C71AB1%22%2C%22com.facebook.sdk_client_state%22%3Atrue%2C%223_method%22%3A%22sfvc_auth%22%7D&scope=user_birthday%2Cuser_photos%2Cuser_education_history%2Cemail%2Cuser_relationship_details%2Cuser_friends%2Cuser_work_history%2Cuser_likes&response_type=token%2Csigned_request&default_audience=friends&return_scopes=true&auth_type=rerequest&client_id=464891386855067&ret=login&sdk=ios&logger_id=30F06532-A1B9-4B10-BB28-B29956C71AB1&ext=1470840777&hash=AeZqkIcf-NEW6vBd"

def get_access_token(email, password):
s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml")
s.open(FB_AUTH)
##submit login form##
f = s.get_form()
f["pass"] = password
f["email"] = email
s.submit_form(f)
##click the 'ok' button on the dialog informing you that you have already authenticated with the Tinder app##
f = s.get_form()
s.submit_form(f, submit=f.submit_fields['CONFIRM'])
##get access token from the html response##
access_token = re.search(r"access_token=([\w\d]+)", s.response.content.decode()).groups()[0]
#print s.response.content.decode()
return access_token

@asharma567 asharma567 closed this Feb 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment