Hi Guys,
'social_core.pipeline.social_auth.auth_allowed',
'apps.integrations.pipelines.shopify_webhook_order_create',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
)
-- I need to create one webhook in shopify(order/product) but using pipeline function.I did the app authentication and got the access taken.
In settings.py i added this
SOCIAL_AUTH_SHOPIFY_WEBHOOK_PIPELINE = (
'social_core.pipeline.social_auth.social_uid','social_core.pipeline.social_auth.auth_allowed',
'apps.integrations.pipelines.shopify_webhook_order_create',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
)
I wanted to do something like this inside "shopify_webhook_order_create"
social = backend.strategy.storage.user.get_social_auth(provider, uid)
if social and not user:
user = social.user
return {'social': social,
'user': user,
'is_new': user is None,
'new_association': social is None}"
def register_webhook():
headers = {
"X-Shopify-Access-Token": session.get("access_token"),
"Content-Type": "application/json"
}
payload = {
"webhook": {
"topic": "draft_orders/create",
"address": "https://{0}/webhook".format(HOST),
"format": "json"
}
}
response = requests.post("https://" + session.get("shop")
+ "/admin/webhooks.json",
data=json.dumps(payload), headers=headers)
if response.status_code == 201:
return render_template('register_webhook.html',
webhook_response=json.loads(response.text))
else:
return Response(response="{0} - {1}".format(response.status_code,
response.text), status=200)
headers = {
"X-Shopify-Access-Token": session.get("access_token"),
"Content-Type": "application/json"
}
payload = {
"webhook": {
"topic": "draft_orders/create",
"address": "https://{0}/webhook".format(HOST),
"format": "json"
}
}
response = requests.post("https://" + session.get("shop")
+ "/admin/webhooks.json",
data=json.dumps(payload), headers=headers)
if response.status_code == 201:
return render_template('register_webhook.html',
webhook_response=json.loads(response.text))
else:
return Response(response="{0} - {1}".format(response.status_code,
response.text), status=200)
but pipeline is having some specific format like below :
"def slack_webhook_social_user(backend, uid, user=None, *args, **kwargs):
provider = backend.namesocial = backend.strategy.storage.user.get_social_auth(provider, uid)
if social and not user:
user = social.user
return {'social': social,
'user': user,
'is_new': user is None,
'new_association': social is None}"
My Question is how can i create webhook using pipeline function.
Thanks,
Saswat
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEhPkLGOAMO4SXXt2Fw8Pu_iEZkc7bx8XOJEQb6dKcepK8XQGA%40mail.gmail.com.
No comments:
Post a Comment