1
websocket connection
Question asked by caner duman - 10/27/2022 at 4:26 PM
Unanswered
Hello i want smarterwebmail client websocket but i cant find connectionToken.

How i can access connectionToken ? with authenticated user api connection

8 Replies

Reply to Thread
0
Zach Sylvester Replied
Employee Post
Hello Canner, 

Thanks for reaching out to the community. Can you please explain a little bit more about what you're trying to do here?
Can you share some API documentation links for the specific calls that you're trying to run?
Looking forward to your response. 

Kind Regards, 
Zach Sylvester Software Developer SmarterTools Inc. www.smartertools.com
0
caner duman Replied
Hello Zach,

İ am use smarter mail api for get messages. but your client use websocket for new messages.


As you can see in the picture, there is a websocket connection.

I also want to connect to websocket. How can I access the connectionToken value required to connect?

i use for login and get messages this api

smartertools.com/Documentation/api#/topics/overview

Thanks.
0
Zach Sylvester Replied
Employee Post
Hello Caner, 

Thanks for the clarification. In order todo that you will need to use the authenticate user API token. 
Here is an example in python. 
import requests

def auth(username, password, url):
    authurl = url + "/api/v1/auth/authenticate-user" 
    myobj = {'username': username, 'password':password} 
    data = requests.post(authurl, data = myobj) # this posts the username and password to the api
    #print(data.json())
    refreshToken = data.json()['refreshToken'] # this is the refresh token
    accessToken = data.json()['accessToken'] # this is the access token
    accessTokenExpiration = data.json()['accessTokenExpiration'] # this is the access token expiration date
    access_info = {'accessToken': accessToken, 'accessTokenExpiration': accessTokenExpiration, 'refreshToken': refreshToken} # this is the access token, refresh token and expiration info
    return access_info # returns the information

creds = auth("username","password","https://yourinstance.com";)


Please let me know if this helps. 

Kind Regards, 
Zach Sylvester Software Developer SmarterTools Inc. www.smartertools.com
0
caner duman Replied
Hello Zach,

Thanks for answer.

I am already able to login with the api.

I need documentation for my websocket operations.

Thanks.
0
Zach Sylvester Replied
Employee Post
Hey Caner, 

Thanks for the follow-up. The WebSocket is used for things like Signal R which is used to refresh the access token and refresh token. You are not really supposed to use this with the API. 
I recommend using these two API calls for getting messages. 


Please let me know if this helps. 

Kind Regards, 
Zach Sylvester Software Developer SmarterTools Inc. www.smartertools.com
0
caner duman Replied
Hello Zach, 

Thanks answer.

yes, I am calling the messages to my page and listing them. There is no problem with that. but when a new e-mail arrives, I cannot see this message without refreshing my page. If I can receive notification of mail with websocket, I can also pull new incoming messages to my page.

Thanks.
0
Zach Sylvester Replied
Employee Post
Hello, 

Thanks for the follow-up. That makes sense. We don't have documentation on using this WebSocket. So you could just have your script check every minute for new messages if that would work for you. 

Kind Regards, 
Zach Sylvester Software Developer SmarterTools Inc. www.smartertools.com
0
caner duman Replied
How can I find the connectionToken value that appears in this picture? https://portal.smartertools.com/AvatarHandler.ashx?postattchid=2038

Reply to Thread