Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e2ce16

Browse files
committed
update docs
1 parent e890bd9 commit 9e2ce16

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

README.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Documentation for this Python client are available at the [Stream website](https
2828
### Usage
2929

3030
```python
31+
import datetime
32+
3133
# Instantiate a new client
3234
import stream
3335
client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET')
@@ -116,15 +118,11 @@ client.activity_partial_update(id=activity_id, set=set, unset=unset)
116118
# ...or by combination of foreign_id and time
117119
client.activity_partial_update(foreign_id=foreign_id, time=activity_time, set=set, unset=unset)
118120

119-
# Generating tokens for client side usage (JS client)
120-
token = user_feed_1.token
121-
# Javascript client side feed initialization
122-
# user1 = client.feed('user', '1', '{{ token }}');
121+
# Generating user token for client side usage (JS client)
122+
user_token = client.create_user_token("user-42")
123123

124-
# Generate a read-only token for client side usage (JS client)
125-
readonly_token = user_feed_1.get_readonly_token()
126124
# Javascript client side feed initialization
127-
# user1 = client.feed('user', '1', '{{ readonly_token }}');
125+
# client = stream.connect(apiKey, userToken, appId);
128126

129127
# Generate a redirect url for the Stream Analytics platform to track
130128
# events/impressions on url clicks
@@ -164,6 +162,15 @@ py.test --cov stream --cov-report html
164162
LOCAL=true py.test
165163
```
166164

165+
Install black and flake8
166+
167+
```
168+
pip install black
169+
pip install flake8
170+
```
171+
172+
Install git hooks to avoid pushing invalid code (git commit will run black and flak8)
173+
167174
### Releasing a new version
168175

169176
In order to release new version you need to be a maintainer on Pypi.

stream/client.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def _parse_response(self, response):
168168
self.raise_exception(parsed_result, status_code=response.status_code)
169169
return parsed_result
170170

171-
def create_user_session_token(self, user_id, **extra_data):
171+
def create_user_token(self, user_id, **extra_data):
172172
"""Setup the payload for the given user_id with optional
173173
extra data (key, value pairs) and encode it using jwt
174174
"""
@@ -177,6 +177,9 @@ def create_user_session_token(self, user_id, **extra_data):
177177
payload[k] = v
178178
return jwt.encode(payload, self.api_secret, algorithm="HS256").decode("utf-8")
179179

180+
def create_user_session_token(self, user_id, **extra_data):
181+
return self.create_user_token(user_id, **extra_data)
182+
180183
def create_jwt_token(self, resource, action, feed_id=None, user_id=None):
181184
"""
182185
Setup the payload for the given resource, action, feed or user

0 commit comments

Comments
 (0)