Annytab.Fortnox.Client/V3/Repositories/FortnoxAuthorizationClient.cs
/// <summary>
/// Get an access token from fortnox
/// </summary>
Get an access token from fortnox
Get an access token from fortnox
public async Task<AuthorizationResponse> GetAccessToken()
        {
            AuthorizationResponse post = new AuthorizationResponse();
            HttpResponseMessage response = await this.client.GetAsync("");
            if (response.IsSuccessStatusCode == true)
            {
                string data = await response.Content.ReadAsStringAsync();
                AuthorizationRoot root = JsonConvert.DeserializeObject<AuthorizationRoot>(data);
                post.success = true;
                post.message = root.Authorization.AccessToken;
            }
            else
            {
                string data = await response.Content.ReadAsStringAsync();
                post.success = false;
                post.message = Regex.Unescape(data);
            }
            return post;
        }
public async Task < AuthorizationResponse > GetAccessToken ( ) { AuthorizationResponse post = new AuthorizationResponse ( ) ; HttpResponseMessage response = await this . client . GetAsync ( " " ) ; if ( response . IsSuccessStatusCode == true ) { string data = await response . Content . ReadAsStringAsync ( ) ; AuthorizationRoot root = JsonConvert . DeserializeObject < AuthorizationRoot > ( data ) ; post . success = true ; post . message = root . Authorization . AccessToken ; } else { string data = await response . Content . ReadAsStringAsync ( ) ; post . success = false ; post . message = Regex . Unescape ( data ) ; } return post ; }
Get an access token from fortnox
Get an access token from fortnox
// Create the response to return // Get the response // Check the status code for the response // Get the access token // Add the access token to the response // Get the error message // Add the error to the response // Return the authorization response