Ejemplo n.º 1
0
        public AccountAuthorizationResponse AuthorizeAccount(ApplicationCredentials credentials)
        {
            CurrentToken = GetCachedAuthorization();

            if (CurrentToken != null && CurrentToken.AccountID == credentials.AccountId)
            {
                return CurrentToken;
            }

            string authString = "{0}:{1}".Fmt(credentials.AccountId, credentials.ApplicationKey);
            byte[] authBytes = Encoding.UTF8.GetBytes(authString);
            client.AddHeader("Authorization", "Basic {0}".Fmt(System.Convert.ToBase64String(authBytes)));
            var response = client.Get<AccountAuthorizationResponse>("b2_authorize_account");

            CurrentToken = response;
            SaveAuthorizationToken(response);

            return CurrentToken;
        }
Ejemplo n.º 2
0
        public void SetUp()
        {
            client = new ServiceStackB2Api();

            //todo: I should not have to re-auth here, what's wrong with this design?
            creds = client.GetApplicationCredentials();
        }