Skip to content

Register a member avatar in Straas

Hsueh-Jen edited this page Aug 25, 2020 · 1 revision

Every Straas member has his own resource access right and his purchase records. Before using any API related to a Straas member(e.g. check member's permission of a VOD), you have to create a relation between your members and Straas members. It is better to construct the relation immediately when your new member signs up completely.

Create a new member

To create a new Straas member, you should get an app token first (How to get an app token?). Once you get the token then send a POST request to Create New Member API to create a new member.

curl -X POST --header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
-d '{ "id":<YOUR_MEMBER'S_ID>, "email":<YOUR_MEMBER'S_EMAIL> }' \
'https://app.straas.net/api/v1/app/members'

A success response will look like this:

{
  "id": "your_member_id",
  "email": "yourmember@email.com"
  "name": null,
  "avatar_url": null,
  "personal_url": null,
  "membership_type": "free"
}

Note that, the pattern of YOUR_MEMBER'S_ID could be

  • email
  • a string with length from 3 to 50, follows regular expression "^[-_A-Za-z0-9]+$"

The detail api reference please see link.

Create a new member for message service

A name and an avatar_url are required in the message SDK.

You may build the two parameters by Create New Member API.

curl -X POST --header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
-d '{ "id":<YOUR_MEMBER'S_ID>, "email":<YOUR_MEMBER'S_EMAIL>, "avatar_url":<YOUR_MEMBER'S_AVATAR_URL> }' \
'https://app.straas.net/api/v1/app/members'

A success response will look like this:

{
  "id": "your_member_id",
  "email": "yourmember@email.com"
  "name": "your member name",
  "avatar_url": "http://your.member.avatar.jpg",
  "personal_url": null,
  "membership_type": "free"
}

You can also update the name and avatar url by Update Member API later.

curl -X PUT --header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
-d '{ "email":<YOUR_MEMBER'S_EMAIL>, "avatar_url":<YOUR_MEMBER'S_AVATAR_URL> }' \
'https://app.straas.net/api/v1/app/members/<YOUR_MEMBER'S_ID>'

A success response looks like this:

{
  "id": "your_member_id",
  "email": "yourmember@email.com"
  "name": "your member new name",
  "avatar_url": "http://your.member.new.avatar.jpg",
  "personal_url": null,
  "membership_type": "free"
}

Retrieve Your Member in Straas

After the member is created, the services of Straas can retrieve the related user information in our services. For security reason, we retrieve the member information through jwt token.

You can learn how to get a member token in get member token. Note that the member token has expired period which is 24 hours, you can build a cache based on this information.

After you get a member token and provide it to our sdk, you can let your members use Straas's service with their own identities.