Creating new user with grpc

148 views
Skip to first unread message

Yogeswari Narayasamy

unread,
Aug 21, 2020, 10:00:22 AM8/21/20
to Tinode General

According to the documentation, we’ll need to set user to “new” to create a new user.

But this doesn’t seem possible via grpc call because the struct ClientAcc doesn’t have the definition for “User”?


I did read the FAQ that mentions the three ways of creating a new user as below:

  • A user can create a new account using one of the applications (web, Android, iOS).

  • A new account can be created using tn-cli (acc command or useradd macro). The process can be scripted.

  • If the user already exists in an external database, the Tinode account can be automatically created on the first login using the rest authenticator.

There's no mention of grpc in the above. Does this mean we can't create new users with grpc calls? 


I'm not familiar with tn-cli & rest authenticator. Can I use one of these to bulk create users on Tinode?

How can I go about it? Appreciate your guidance on this, thank you.


Gene Sokolov

unread,
Aug 21, 2020, 11:59:19 AM8/21/20
to tin...@googlegroups.com
On Fri, Aug 21, 2020 at 7:00 AM Yogeswari Narayasamy <yogeswari....@gmail.com> wrote:

According to the documentation, we’ll need to set user to “new” to create a new user.

But this doesn’t seem possible via grpc call because the struct ClientAcc doesn’t have the definition for “User”?


UserId.
 


I did read the FAQ that mentions the three ways of creating a new user as below:

  • A user can create a new account using one of the applications (web, Android, iOS).

  • A new account can be created using tn-cli (acc command or useradd macro). The process can be scripted.

  • If the user already exists in an external database, the Tinode account can be automatically created on the first login using the rest authenticator.

There's no mention of grpc in the above. Does this mean we can't create new users with grpc calls? 


I'm not familiar with tn-cli & rest authenticator. Can I use one of these to bulk create users on Tinode?

How can I go about it? Appreciate your guidance on this, thank you.


--
You received this message because you are subscribed to the Google Groups "Tinode General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tinode+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tinode/0204e78b-7f69-444d-b404-dcb5c05787d5o%40googlegroups.com.

Yogeswari Narayasamy

unread,
Aug 24, 2020, 5:23:13 AM8/24/20
to Tinode General
I updated the code as below:
requests := []*pbx.ClientMsg{
       &pbx.ClientMsg{
           Message: &pbx.ClientMsg_Hi{Hi: &pbx.ClientHi{
               Id:        "1",
               UserAgent: "Golang_Spider_Bot/3.0",
               Ver:       "0.15",
               Lang:      "EN",
           }},
       },
       &pbx.ClientMsg{
           Message: &pbx.ClientMsg_Acc{
               Acc: &pbx.ClientAcc{
                   Id:     "2",
                   UserId: "new",
                   Scheme: "basic",
                   Secret: []byte(`"bxbx:bxbx123"`),
                   Login:  true,
                   Desc: &pbx.SetDesc{
                       Public: []byte(`"fn:Bxbx MHub"`),
                   },
                   Cred: []*pbx.ClientCred{
                       &pbx.ClientCred{
                           Method: "email",
                           Value:  "bx...@example.com",
                       },
                   },
                   // Tags: []string{"mhub:cog-user-id-0123456789-bwbw"},
                   Tags: []string{"email:bx...@example.com"},
               },
           },
       },
   }
But I'm unable to sign in with this cred:
Log:
09:18:23.590] Connecting to:  wss://dev.mhub.my:6060/v0/channels?apikey=AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K tinode.prod.js:1:18606
[09:18:23.649] out: {"hi":{"id":"104562","ver":"0.16.5","ua":"TinodeWeb/0.16.5 (Firefox/79.0; Linux x86_64); tinodejs/0.16.5","lang":"en-US"}} <empty string> tinode.prod.js:1:18606
[09:18:23.654] in: {"ctrl":{"id":"104562","params":{"build":"rethinkdb:undef","maxFileUploadSize":8388608,"maxMessageSize":262144,"maxSubscriberCount":128,"maxTagCount":16,"ver":"0.16"},"code":201,"text":"created","ts":"2020-08-24T09:18:23.653Z"}} <empty string> tinode.prod.js:1:18606
[09:18:23.657] out: {"login":{"id":"104563","scheme":"basic","secret":"YnhieDpieGJ4MTIz"}} <empty string> tinode.prod.js:1:18606
[09:18:23.662] in: {"ctrl":{"id":"104563","code":401,"text":"authentication failed","ts":"2020-08-24T09:18:23.661Z"}} <empty string>
How can I rectify this?


On Friday, 21 August 2020 23:59:19 UTC+8, Gene wrote:


On Fri, Aug 21, 2020 at 7:00 AM Yogeswari Narayasamy <yogeswari...@gmail.com> wrote:

According to the documentation, we’ll need to set user to “new” to create a new user.

But this doesn’t seem possible via grpc call because the struct ClientAcc doesn’t have the definition for “User”?


UserId.
 


I did read the FAQ that mentions the three ways of creating a new user as below:

  • A user can create a new account using one of the applications (web, Android, iOS).

  • A new account can be created using tn-cli (acc command or useradd macro). The process can be scripted.

  • If the user already exists in an external database, the Tinode account can be automatically created on the first login using the rest authenticator.

There's no mention of grpc in the above. Does this mean we can't create new users with grpc calls? 


I'm not familiar with tn-cli & rest authenticator. Can I use one of these to bulk create users on Tinode?

How can I go about it? Appreciate your guidance on this, thank you.


--
You received this message because you are subscribed to the Google Groups "Tinode General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tin...@googlegroups.com.

Yogeswari Narayasamy

unread,
Aug 24, 2020, 6:03:55 AM8/24/20
to Tinode General
I have two additional questions based on the same code previously shared:

1. When I search for user bxbx by email address, I'm getting a result but it's appearing as 'Unnamed". How can I get the user name to display correctly?
2. When I create a new user "Abcd" and try to set Tags to "Tags: []string{"mhub:cog-user-id-0123456789-abcd"},", it fails :

        &pbx.ClientMsg{
           Message: &pbx.ClientMsg_Acc{
               Acc: &pbx.ClientAcc{
                   Id:     "2",
                   UserId: "new",
                   Scheme: "basic",
                   Secret: []byte(`"abcd:abcd123"`),
                   Login:  true,
                   Desc: &pbx.SetDesc{
                       Public: []byte(`"fn:Abcd MHub"`),
                   },
                   Cred: []*pbx.ClientCred{
                       &pbx.ClientCred{
                           Method: "email",
                           Value:  "ab...@example.com",
                       },
                   },
                   Tags: []string{"mhub:cog-user-id-0123456789-abcd"},
               },
           },
       },

The error message says: "2020/08/24 17:51:47 create user: attempt to directly assign restricted tags 8t1b-69YE1k"

2020/08/24 17:51:46 grpc in: hi:<id:"1" user_agent:"Golang_Spider_Bot/3.0" ver:"0.15" lang:"EN" >  8t1b-69YE1k
2020/08/24 17:51:47 grpc in: acc:<id:"2" user_id:"new" scheme:"basic" secret:"\"abcd:abcd123\"" login:true tags:"mhub:cog-user-id-0123456789-abcd" desc:<public:"\"fn:Abcd MHub\"" > cred:<method:"email" value:"ab...@example.com" > >  8t1b-69YE1k
2020/08/24 17:51:47 create user: attempt to directly assign restricted tags 8t1b-69YE1k

I have a requirement to be able to search by "mhub:xxxx". There's a user "yoges" previously created with front-end code that I'm able to find this way:
How can I modify my code to make it work?


Thank you for reading.
                   Tags: []string{"email:bxbx@example.com"},
               },
           },
       },
   }

yoges nsamy

unread,
Aug 24, 2020, 10:37:30 PM8/24/20
to tin...@googlegroups.com
Hi Gene, would you have some feedback on these questions? Appreciate your input. Thank you.


                   Tags: []string{"email:bx...@example.com"},
               },
           },
       },
   }
To unsubscribe from this group and stop receiving emails from it, send an email to tinode+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tinode/0bc15fb2-31c7-4108-900c-70276714c248o%40googlegroups.com.

Gene

unread,
Aug 25, 2020, 4:40:33 PM8/25/20
to Tinode General
On Monday, August 24, 2020 at 7:37:30 PM UTC-7 Yogeswari Narayasamy wrote:
Hi Gene, would you have some feedback on these questions? Appreciate your input. Thank you.


On Mon, Aug 24, 2020 at 6:03 PM Yogeswari Narayasamy <yogeswari....@gmail.com> wrote:
I have two additional questions based on the same code previously shared:

1. When I search for user bxbx by email address, I'm getting a result but it's appearing as 'Unnamed". How can I get the user name to display correctly?

Please show server-side and client-side logs.
 
2. When I create a new user "Abcd" and try to set Tags to "Tags: []string{"mhub:cog-user-id-0123456789-abcd"},", it fails :

Have you added mhub to tinode.conf as a restricted tag?

Yogeswari Narayasamy

unread,
Aug 26, 2020, 12:49:29 AM8/26/20
to Tinode General
1. When I search for user bxbx by email address, I'm getting a result but it's appearing as 'Unnamed". How can I get the user name to display correctly?

Please show server-side and client-side logs.

 
It turned out that I wasn't formatting "public" in the expected format.
When I corrected
Public: []byte(`"fn:Efgh MHub Consumer"`),
to
Public: []byte(`{"fn":"Sharon Gan"}`),
The user name is displayed correctly:
But I'm still not able to login as sharon.
Server log:
2020/08/26 12:03:12 ws: session started -HDHWknnwqQ 1
2020/08/26 12:03:12 in: '{"hi":{"id":"111095","ver":"0.16.5","ua":"TinodeWeb/0.16.5 (Firefox/79.0; Linux x86_64); tinodejs/0.16.5","lang":"en-US"}}' ip='127.0.0.1:38184' sid='-HDHWknnwqQ' uid=''
2020/08/26 12:03:12 in: '{"login":{"id":"111096","scheme":"basic","secret":"c2hhcm9uOnNoYXJvbjEyMw=="}}' ip='127.0.0.1:38184' sid='-HDHWknnwqQ' uid=''
2020/08/26 12:04:19 in: '{"login":{"id":"111097","scheme":"basic","secret":"c2hhcm9uOnNoYXJvbjEyMw=="}}' ip='127.0.0.1:38184' sid='-HDHWknnwqQ' uid=''
Browser log:
[04:04:19.950] out: {"login":{"id":"111097","scheme":"basic","secret":"c2hhcm9uOnNoYXJvbjEyMw=="}} <empty string> tinode.prod.js:1:18606
[04:04:19.974] in: {"ctrl":{"id":"111097","code":401,"text":"authentication failed","ts":"2020-08-26T04:04:19.953Z"}} <empty string>

The code to create user sharon:
    requests := []*pbx.ClientMsg{
        &pbx.ClientMsg{
            Message: &pbx.ClientMsg_Hi{Hi: &pbx.ClientHi{
                Id:        "1",
                UserAgent: "Golang_Spider_Bot/3.0",
                Ver:       "0.15",
                Lang:      "EN",
            }},
        },
        &pbx.ClientMsg{
            Message: &pbx.ClientMsg_Acc{
                Acc: &pbx.ClientAcc{
                    Id:     "2",
                    UserId: "new",
                    Scheme: "basic",                      // basic
                    Secret: []byte(`"sharon:sharon123"`), // bob:bob123
                    Login:  true,
                    Desc: &pbx.SetDesc{
                        Public: []byte(`{"fn":"Sharon Gan"}`),
                    },
                    Cred: []*pbx.ClientCred{
                        &pbx.ClientCred{Method: "email", Value: "sha...@example.com"},
                    },
                    Tags: []string{"email:sha...@example.com"}, // need this, otherwise can't find user
                },
            },
        },
    }
Server log while creating sharon:
2020/08/26 11:45:44 grpc in: hi:<id:"1" user_agent:"Golang_Spider_Bot/3.0" ver:"0.15" lang:"EN" >  Ztc4nh8xt-U
2020/08/26 11:45:45 grpc in: acc:<id:"2" user_id:"new" scheme:"basic" secret:"\"sharon:sharon123\"" login:true tags:"email:sha...@example.com" desc:<public:"{\"fn\":\"Sharon Gan\"}" > cred:<method:"email" value:"sha...@example.com" > >  Ztc4nh8xt-U
2020/08/26 11:45:45 add cred tags update failed: <nil>
2020/08/26 11:45:58 in: '{"set":{"id":"83325","topic":"fnd","desc":{"public":"email:sha...@example.com"}}}' ip='127.0.0.1:35786' sid='2kg4f_V45GQ' uid='N903mmDxSbQ'
2020/08/26 11:45:58 in: '{"get":{"id":"83326","topic":"fnd","what":"sub"}}' ip='127.0.0.1:35786' sid='2kg4f_V45GQ' uid='N903mmDxSbQ'
Client log while creating sharon:
Starting to do a createUser BiDi Streaming RPC...
Sending message: hi:<id:"1" user_agent:"Golang_Spider_Bot/3.0" ver:"0.15" lang:"EN" >
Received: &{id:"1" code:201 text:"created" params:<key:"build" value:"\"rethinkdb:undef\"" > params:<key:"maxFileUploadSize" value:"8388608" > params:<key:"maxMessageSize" value:"262144" > params:<key:"maxSubscriberCount" value:"128" > params:<key:"maxTagCount" value:"16" > params:<key:"ver" value:"\"0.16\"" > }
Sending message: acc:<id:"2" user_id:"new" scheme:"basic" secret:"\"sharon:sharon123\"" login:true tags:"email:sha...@example.com" desc:<public:"{\"fn\":\"Sharon Gan\"}" > cred:<method:"email" value:"sha...@example.com" > >
Received: &{id:"2" code:200 text:"ok" params:<key:"authlvl" value:"\"auth\"" > params:<key:"desc" value:"{\"created\":\"2020-08-26T03:45:45.379Z\",\"updated\":\"2020-08-26T03:45:45.379Z\",\"defacs\":{\"auth\":\"JRWPAS\",\"anon\":\"N\"},\"public\":{\"fn\":\"Sharon Gan\"}}" > params:<key:"expires" value:"\"2020-09-09T03:45:45.49Z\"" > params:<key:"token" value:"\"m7EJawhymvPpT1hfFAABAAEActMRMjpjgdWXAyFMKba6v2U3tX3vWsHQD0grfIIOGuU=\"" > params:<key:"user" value:"\"usrm7EJawhymvM\"" > }


Reply all
Reply to author
Forward
0 new messages