Created
August 3, 2017 15:17
-
-
Save psapir/1d69479fda86d769cf3c5e3e6d0d4e84 to your computer and use it in GitHub Desktop.
Writing a REST Service with Cloud Pages - GetAccessToken Method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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