private IDictionary <string, string> AuthHeaders()
 {
     if (_sessionRepository == null || string.IsNullOrEmpty(_sessionRepository.Session._token))
     {
         return(null);
     }
     else
     {
         return(FizzUtils.Headers(_sessionRepository.Session._token));
     }
 }
        public void FetchToken(Action <FizzSession, FizzException> callback)
        {
            _sessionProvider.FetchToken(_userId, _locale, (session, exception) => {
                if (exception == null)
                {
                    Session = session;

                    FizzUtils.DoCallback(OnSessionUpdate);
                }

                FizzUtils.DoCallback <FizzSession>(session, exception, callback);
            });
        }
        public void Get(string host,
                        string path,
                        IDictionary <string, string> headers,
                        Action <string, FizzException> callback)
        {
            Action <string, FizzException> onDone = FizzUtils.SafeCallback(callback);

            SendRequestAsync(host, path, "GET", headers, CONTENT_TYPE, 0, null, (status, response, ex) =>
            {
                if (ex != null)
                {
                    FizzUtils.DoCallback(null, ex, onDone);
                }
                else
                {
                    FormatResponse(status, response, onDone);
                }
            });
        }
Exemple #4
0
        public void FetchToken(string userId, string locale, Action <FizzSession, FizzException> callback)
        {
            if (string.IsNullOrEmpty(locale))
            {
                FizzUtils.DoCallback <FizzSession>(new FizzSession(null, null, 0), ERROR_INVALID_LOCALE, callback);
                return;
            }

            JSONClass node = new JSONClass();

            node["user_id"] = userId;
            node["locale"]  = locale;
            node["app_id"]  = _appId;

            string body    = node.ToString();
            string digest  = GenerateHmac(body, _appSecret);
            var    headers = new Dictionary <string, string>()
            {
                { "Authorization", "HMAC-SHA256 " + digest }
            };

            _restClient.Post(FizzConfig.API_BASE_URL, FizzConfig.API_PATH_SESSIONS, body, headers, (response, ex) =>
            {
                if (ex != null)
                {
                    FizzUtils.DoCallback(new FizzSession("", "", FizzUtils.Now()), ex, callback);
                }
                else
                {
                    try
                    {
                        FizzSession session = ParseSession(JSONNode.Parse(response));
                        FizzUtils.DoCallback(session, null, callback);
                    }
                    catch (Exception responseEx)
                    {
                        FizzLogger.E(responseEx.Message);
                        FizzUtils.DoCallback(new FizzSession("", "", FizzUtils.Now()), ERROR_SESSION_CREATION_FAILED, callback);
                    }
                }
            });
        }
Exemple #5
0
 public void FetchSessionToken(Action <FizzException> callback)
 {
     FizzUtils.DoCallback(null, callback);
 }