Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Writing a REST Service with Cloud Pages - GetAccessToken Method
If @action == "GetAccessToken" and not empty (@pass) and not empty (@Email)then
set @rows = LookupRows("Register","EmailAddress",@Email,"Pass",@pass)
set @rowCount = rowcount(@rows)
If @rowCount == 0 then
set @json= '{"Status":"error", "message":" the Email address or password are incorrect"}'
output(v(@json))
Endif
If @rowCount > 0 then
set @row = row(@rows,1)
set @EntryCode = field(@row,"EntryCode")
set @data=concat(@Email,@pass)
set @encodedStr = Base64Encode(@data)
set @data=concat(@encodedStr,@EntryCode)
set @encodedStr = Base64Encode(@data)
UpsertDe("Rest api authorization",1,"EntryCode",@EntryCode,"AccessToken",@encodedStr,"EmailAddress",@Email)
set @AccessTokenJson ='{"status":"ok","AccessToken":"'
set @AccessTokenJson=concat(@AccessTokenJson,@encodedStr,'"}')
output(v(@AccessTokenJson))
endif
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment