@@ -64,38 +64,53 @@ these steps:
64
64
```
65
65
66
66
3 . For application to access a shop via the API , they first need a
67
- " token" specific to the shop, which is obtained from Shopify after
68
- the owner has granted the application access to the shop. This can
69
- be done by redirecting the shop owner to permission URL obtained
70
- as follows:
67
+ " access token" specific to the shop, which is obtained from
68
+ Shopify after the owner has granted the application access to the
69
+ shop. This can be done by redirecting the shop owner to a
70
+ permission URL , obtained as follows:
71
71
72
72
```python
73
73
shop_url = " yourshopname.myshopify.com"
74
74
permission_url = shopify.Session.create_permission_url(shop_url)
75
75
```
76
76
77
77
4 . After visiting this URL , the shop redirects the owner to a custom
78
- URL of your application where the ` token` gets sent to (it ' s param
79
- name is just `t` ) along with other parameters to ensure it was sent
80
- by Shopify. That token is used to instantiate the session so that it
81
- is ready to make calls to that particular shop.
78
+ URL of your application where the encoded access token gets sent
79
+ as the `t` param. The following code will validate taht the request
80
+ came from Shopify, then decode the permanent access token which
81
+ can be used to make API requests for this shop.
82
82
83
83
```python
84
84
session = shopify.Session(shop_url, params)
85
85
```
86
86
87
- 5 . Now you can finally get the fully authorized URL for that shop.
88
- Use that URL to configure ActiveResource and you ' re set:
87
+ 5 . Activate the session to use the access token for following API
88
+ requests for the shop it was authorized for .
89
89
90
90
```python
91
- shopify.ShopifyResource.site = session.site
91
+ shopify.ShopifyResource.activate_session( session)
92
92
```
93
93
94
- 6 . Get data from that shop (returns ActiveResource instances):
94
+ 6 . Start making authorized API requests for that shop. Data is returned as
95
+ ActiveResource instances:
95
96
96
97
```python
97
- shop = shopify.Shop.current()
98
- latest_orders = shopify.Order.find()
98
+ # Get a list of products
99
+ products = shopify.Product.find()
100
+
101
+ # Get a specific product
102
+ product = shopify.Product.find(632910 )
103
+
104
+ # Create a new product
105
+ new_product = shopify.Product()
106
+ new_product.title = " Burton Custom Freestlye 151"
107
+ new_product.product_type = " Snowboard"
108
+ new_product.vendor = " Burton"
109
+ new_product.save()
110
+
111
+ # Update a product
112
+ product.handle = " burton-snowboard"
113
+ product.save()
99
114
```
100
115
101
116
# ## Console
@@ -148,8 +163,9 @@ easy_install dist/ShopifyAPI-*.tar.gz
148
163
149
164
# # Limitations
150
165
151
- Currently there is not support for :
166
+ Currently there is no support for :
152
167
168
+ * OAuth2
153
169
* python 3
154
170
* asynchronous requests
155
171
* persistent connections
0 commit comments