OAuthAPI.ExtractTokenFromHTTPRequest
Return the OAuth access token.
Syntax
ExtractTokenFromHTTPRequest(
req comm.HttpServiceRequest)
RETURNS STRING
- req is a
com.HttpServiceRequest
object.
Returns the access token. NULL
may be returned if the access token is not
found.
Usage
Use this function to extract the access token from an com.HttpServiceRequest
object accessing a RESTful Web service.
In case of error, a NULL
value will be returned.
OAuthAPI.ExtractTokenFromHTTPRequest function
IMPORT com
IMPORT FGL OAuthAPI
MAIN
DEFINE req com.HttpServiceRequest
DEFINE access_token STRING
TRY
# Start server for all registered Web Services
CALL com.WebServiceEngine.Start()
WHILE TRUE
LET req = com.WebServiceEngine.GetHttpServiceRequest(-1)
IF req IS NULL THEN
DISPLAY "HTTP request timeout...: ", CURRENT YEAR TO FRACTION
EXIT PROGRAM 1
ELSE
# Retrieve access token
LET access_token = OAuthAPI.ExtractTokenFromHTTPRequest(req)
IF access_token IS NOT NULL THEN
DISPLAY "token is: ", access_token
END IF
END IF
END WHILE
CATCH
DISPLAY "ERROR : ",status,sqlca.sqlerrm
EXIT PROGRAM 1
END TRY
END MAIN