Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to retrieve a response #7

Open
kcruzado opened this issue Feb 10, 2016 · 1 comment
Open

Failing to retrieve a response #7

kcruzado opened this issue Feb 10, 2016 · 1 comment

Comments

@kcruzado
Copy link

I am noticing an issue with receiving a response which causes the application to hang. This is happening randomly. With the Rest API I notice this happening in two different scenarios.

a. This happens when waiting for a response for a new access token. This might be related to a deadlock issue with the context.
HttpHelper.cs : await client.PostAsync(oauthTokenEndPoint, new FormUrlEncodedContent(post));

b. It also happens when I try to retrieve a folder. It only happens here if I already have a valid access token and don’t need to get a new one. In this scenario the application doesn’t hang, but it fails to retrieve the folder, causing the folder object to be null.
var folder = vaultApi.Folders.GetFolderByPath(folderPath);

Again, this is happening randomly; so sometimes it works. I’m not sure what is causing this, but I think it might have something to do with the Rest API failing to receive a json response.

@kcruzado
Copy link
Author

Adding the following code to the VaultApi constructors might fix this issue.

Task atx = null;
Task.Run(() => atx = GetAccessToken(clientSecrets.OAuthTokenEndPoint, clientSecrets.ApiKey, clientSecrets.ApiSecret)).Wait();

if(atx != null)
this.ApiTokens = atx.Result;

and create a new method in the VaultApi class...
private async Task GetAccessToken(string oauthTokenEndPoint, string apiKey, string apiSecret)
{
return await HttpHelper.GetAccessToken(oauthTokenEndPoint, apiKey, apiSecret);
}

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

No branches or pull requests

1 participant