fixing callback urls
This commit is contained in:
parent
5e3d8050aa
commit
d078883cd4
@ -62,6 +62,8 @@ frappe.ui.form.on('LinkedIn Settings', {
|
||||
callback : function(r) {
|
||||
window.location.href = r.message;
|
||||
}
|
||||
}).fail(function() {
|
||||
frappe.dom.unfreeze();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -15,7 +15,7 @@ class LinkedInSettings(Document):
|
||||
params = urlencode({
|
||||
"response_type":"code",
|
||||
"client_id": self.consumer_key,
|
||||
"redirect_uri": get_site_url(frappe.local.site) + "/?cmd=erpnext.crm.doctype.linkedin_settings.linkedin_settings.callback",
|
||||
"redirect_uri": get_site_url(frappe.local.site) + "/api/method/erpnext.crm.doctype.linkedin_settings.linkedin_settings.callback?",
|
||||
"scope": "r_emailaddress w_organization_social r_basicprofile r_liteprofile r_organization_social rw_organization_admin w_member_social"
|
||||
})
|
||||
|
||||
@ -30,7 +30,7 @@ class LinkedInSettings(Document):
|
||||
"code": code,
|
||||
"client_id": self.consumer_key,
|
||||
"client_secret": self.get_password(fieldname="consumer_secret"),
|
||||
"redirect_uri": get_site_url(frappe.local.site) + "/?cmd=erpnext.crm.doctype.linkedin_settings.linkedin_settings.callback",
|
||||
"redirect_uri": get_site_url(frappe.local.site) + "/api/method/erpnext.crm.doctype.linkedin_settings.linkedin_settings.callback?",
|
||||
}
|
||||
headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
@ -154,7 +154,7 @@ class LinkedInSettings(Document):
|
||||
|
||||
return response
|
||||
|
||||
@frappe.whitelist()
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def callback(code=None, error=None, error_description=None):
|
||||
if not error:
|
||||
linkedin_settings = frappe.get_doc("LinkedIn Settings")
|
||||
|
@ -47,6 +47,8 @@ frappe.ui.form.on('Twitter Settings', {
|
||||
callback : function(r) {
|
||||
window.location.href = r.message;
|
||||
}
|
||||
}).fail(function() {
|
||||
frappe.dom.unfreeze();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -12,13 +12,12 @@ from tweepy.error import TweepError
|
||||
|
||||
class TwitterSettings(Document):
|
||||
def get_authorize_url(self):
|
||||
callback_url = "{0}/?cmd=erpnext.crm.doctype.twitter_settings.twitter_settings.callback".format(frappe.utils.get_url())
|
||||
callback_url = "{0}/api/method/erpnext.crm.doctype.twitter_settings.twitter_settings.callback?".format(frappe.utils.get_url())
|
||||
auth = tweepy.OAuthHandler(self.consumer_key, self.get_password(fieldname="consumer_secret"), callback_url)
|
||||
|
||||
try:
|
||||
redirect_url = auth.get_authorization_url()
|
||||
return redirect_url
|
||||
except:
|
||||
except tweepy.TweepError as e:
|
||||
frappe.msgprint(_("Error! Failed to get request token."))
|
||||
frappe.throw(_('Invalid {0} or {1}').format(frappe.bold("Consumer Key"), frappe.bold("Consumer Secret Key")))
|
||||
|
||||
@ -91,8 +90,12 @@ class TwitterSettings(Document):
|
||||
frappe.db.commit()
|
||||
frappe.throw(content["message"],title="Twitter Error {0} {1}".format(e.response.status_code, e.response.reason))
|
||||
|
||||
@frappe.whitelist()
|
||||
def callback(oauth_token, oauth_verifier):
|
||||
twitter_settings = frappe.get_single("Twitter Settings")
|
||||
twitter_settings.get_access_token(oauth_token,oauth_verifier)
|
||||
frappe.db.commit()
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def callback(oauth_token = None, oauth_verifier = None):
|
||||
if oauth_token and oauth_verifier:
|
||||
twitter_settings = frappe.get_single("Twitter Settings")
|
||||
twitter_settings.get_access_token(oauth_token,oauth_verifier)
|
||||
frappe.db.commit()
|
||||
else:
|
||||
frappe.local.response["type"] = "redirect"
|
||||
frappe.local.response["location"] = get_url_to_form("Twitter Settings","Twitter Settings")
|
||||
|
Loading…
Reference in New Issue
Block a user