Skip to content

Conversation

@Michael-Gendotti
Copy link

@Michael-Gendotti Michael-Gendotti commented Oct 18, 2017

This change is Reviewable

byte[] authParamBytes = Encoding.ASCII.GetBytes(unencoded);
string encodedAuthParams = Convert.ToBase64String(authParamBytes);
return encodedAuthParams;
if (tokenType == TokenType.Basic)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but a switch statement might be more idiomatic for this purpose.

private int? maxRetries;

public PlanGridHttpHandler(string accessToken, RefitSettings settings, string version, int? maxRetries)
public PlanGridHttpHandler(string accessToken, RefitSettings settings, string version, int? maxRetries, TokenType tokenType = TokenType.Basic)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will probably require some callsite changes in PlanGridApiClient:

https://github.com/plangrid/plangrid-api-net/blob/master/PlanGrid.Api/PlanGridClient.cs#L50

            var api = (AutoGeneratedIPlanGridApi)RestService.For<IPlanGridApi>(
                new HttpClient(new PlanGridHttpHandler(apiKey, settings, version, maxRetries))
                {
                    BaseAddress = new Uri(url), Timeout = TimeSpan.FromSeconds(timeout)
                },
                settings);

i.e. you'll want to surface this new type in the Create method so clients have the opportunity to override the default scheme.

}

request.Headers.Authorization = new AuthenticationHeaderValue("Basic", authenticationToken);
request.Headers.Authorization = new AuthenticationHeaderValue(this.tokenType, authenticationToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this won't compile? i.e. you probably need a .ToString() at the end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants