Shopify app: adding a new shipping address via webhook - python

I'm planning to create a simple app using Django/Python that shows a nice button when installed by the store owner on user's account.
Clicking on that button should trigger a webhook request to our servers that would send back the generated shipping address for the user.
My questions:
Is it possible to create such button through shopify API or this something the store owner must manually add?
Is it possible to add a shipping address upon user request?
Thanks

Here is the recipe:
create a Proxy in your App to accept incoming Ajax call from customer
create a form and button in customer liquid that submits to your Proxy
in the App Proxy, validate the call from Shopify and when valid, look for your form params.
open the customer record with the ID of the customer you sent along with the form data, and add an address to their account
Done. Simple.

Related

Django PayPal for the association of an automatic email sending

Hi everyone I would like to know how you were able to manage once the customer clicks on the paypal payment button in your Django app, I would like to know how you were able to automatically manage sending an email in his mailbox
indeed I can already manage the sending of emails automatically for a button button that I created myself but the case where I used the integration of paypal on the client side, I can't do it
If you want your server to take action when there is a payment, you should be using a server-side integration. Full stop.
Create two routes that return JSON, one for 'Create an Order' and one for 'Capture Order', documented here.
Pair your two routes with the PayPal JS for approval: https://developer.paypal.com/demo/checkout/#/pattern/server
When an order is successfully captured by your server, have your server then immediately take the desired action (send the email). This is straightforward.

Integrate Django authentication with Enterprise Identity Provider PingFederate

We developed web apps in django framework. We have an enterprise Identity Provider which is PingFederate. The main home page (which is different from our site) from chrome browser and edge browser directly recognizes the user and logs them in all the internal websites. We are also on the same network share same domain. We also want to integrate SSO and want to authenticate our users directly with asking password. I researched every where and got to know the authentication is happening by kerbose authentication. Somehow the edge or chrome is sending some token or id or some TGT ticket to the Identity Provider then they will authenticate and send the username back to the client browser. Can any one please help me how to solve this.
Thanks in advance.
I solved this problem and wrote an article about it. Please feel free to see that article.
https://medium.com/#manishkumar.bobbili3/how-i-integrated-ping-identity-with-django-web-framework-for-single-sign-on-sso-9be21b953bc5
It sounds like you want to integrate with the PingFederate solution to use it as the identity provider and allow the users of your web apps to login through SSO. If that is the case, you would need to work with whoever responsible for PingFedereate if it is another team.
Checklist with the PingFederate Admin
You would need to know if you need to choose the directory will be used to log the users in.
Which user attributes you would need to get back in the SAML response.
Will you sign the SAML request using your app or not.
Will you start the SSO cycle from your app, which I believe you would, and you will be using SP initiated in this case.
Otherwise, it will be the other way around and will be using IDP Initiated.
SP Initiated - User will call the app URL first and then redirected
to Ping URL and be sent back to the app.
IDP Initiated - User will call PingFederate URL and will be sent to the app after authentication.
I will list the steps in here in case it is your team who is also responsible for PingFederate solution:
Changes in PingFederate as SP (service provider) connection
Create a new IDP (Identity Provider) Adapter for the login page if needed.
IDP adapter will be using a Password Credential Validator to do the authentication and also has the configuration for which HTML pages to present to the user.
Create the SP connection in Ping with the stuff in the check list.
The connection here will use the adapter in the step above to present the login page
Then check the user credentials and establish the SSO session if successful.
Assemble the SAML response with all the required attributes.
Sign the response and send it to the application endpoint configured inside the connection.
Changes in the web app as the service provider for the user
The application will need to send the SAML request to the endpoint of the new connection in Ping.
Wait for the response on the dedicated endpoint.
Verify the SAML response signature using the PingFederate server's public key.
Create the local app session and move on.
If you will be using OpenToken, this will change to have another interaction of Adapter-to-Adapter. Just reply with that if this is the case.

"Become customer" button on my website requires the POST customer endpoint to be public. I don't want it public. How do I get around this?

I have a web app communicating with a backend through a couple of REST endpoints.
I also have a home page where people can become customers to the above mentioned web app.
All the web app's endpoints requires authentication (a logged in user) to be called (JWT tokens) but on my home page I have a "Become customer" button which makes a POST /customers request, which I have to leave public (But I don't want anyone to be able to spam my endpoint with new customers.
What is the standard way of getting around this problem?
I'm using Python, Flask and Flask-JWT in my backend.
The only option would be a user role that is added, for a limited amount of time (30mins). If the user has this role, then they have permission to view it.
Make sense?

How to Authenticate a Django user from another application

I want to redirect a user from my Django application to another web application. Only permitted users can be allowed access to visit the other web application, this permission is set in the Django User model. I want that other web application to verify whether the visited user has permission by querying the Django application using API endpoint.
But the other web application no longer has the request.user parameter or other way to authenticate the user based on Django User model (don't wan't him to login again). Is there any way like setting a cross-domain session cookie or something, i can achieve it?
I did that recently.
You don't even need the second app to retrieve the users, you can create those users on the fly!
On the first app, have them click a url that will do a very special GET request to the other app.
The GET request will encode a few variables with hmac. Name, emails, or any other values you need using a particular SECRET_KEY that both server will share.
In the second app, you can decode that request with the same SECRET_KEY and log in your user.
See : https://docs.python.org/3/library/hmac.html

Single page application losing custom headers after a refresh

I am building a single page web application (angularjs + python) where a user first needs to login with a username and password. After the user gets authenticated, a new custom header with a token is created and sent everytime this application makes calls to the python api.
One thing I noticed though, is that if I refresh the page (with F5 or Ctrl+F5) then the browser loses this custom header, so it is not sent anymore to the api.
Is there a way to keep the custom headers even after a refresh of the page?
Store the token in sessionStorage or localStorage. In your application startup (config or run) look for this information and set your header.
Perhaps if your user selects "remember me" when they log-in; save the token in local storage otherwise keep it in session storage.

Categories