Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,19 @@ public async Task<IActionResult> GetFoldersFromDropbox()

return Content(response);
}

public async Task<IActionResult> GetAssetsFromAssetBank(string assetIds)
{
AssetBankSearchResponse? response = await _authorizedServiceCaller.GetRequestAsync<AssetBankSearchResponse>(
"assetBank",
"/assetbank-rya-assets-test/rest/asset-search?assetIds=" + assetIds);

if (response == null)
{
return Problem("Could not retrieve assets.");
}

return Content(string.Join(", ", response.Select(x => x.ToString())));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Text.Json.Serialization;

namespace Umbraco.AuthorizedServices.TestSite.Models.ServiceResponses;

public class AssetBankSearchResponse : List<AssetBankAsset>
{
}

public class AssetBankAsset
{
public int Id { get; set; }

[JsonPropertyName("originalFilename")]
public string OriginalFileName { get; set; } = string.Empty;

public override string ToString() => $"{OriginalFileName} ({Id})";
}



Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"AuthorizationUrlRequiresRedirectUrl": {
"type": "boolean",
"description": "Gets or sets the path for requests for working with service tokens."
"description": "Gets or sets a value indicating whether authorization requests require sending the redirect URL."
},
"RequestTokenPath": {
"type": "string",
Expand All @@ -74,6 +74,14 @@
"type": "string",
"description": "Gets or sets the format to use for encoding the request for a token."
},
"JsonSerializer": {
"type": "string",
"description": "Gets or sets the JSON serializer to use when building requests and deserializing responses."
},
"AuthorizationRequestRequiresAuthorizationHeaderWithBasicToken": {
"type": "boolean",
"description": "Gets or sets a value indicating whether the basic token should be included in the token request."
},
"ClientId": {
"type": "string",
"description": "Gets or sets the client Id for the app registered with the service."
Expand Down
16 changes: 16 additions & 0 deletions examples/Umbraco.AuthorizedServices.TestSite/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@
"AuthorizedServices": {
"TokenEncryptionKey": "",
"Services": [
{
"Alias": "assetBank",
"DisplayName": "Asset Bank",
"ApiHost": "https://rya-assets-test.assetbank-server.com",
"IdentityHost": "https://rya-assets-test.assetbank-server.com",
"TokenHost": "https://rya-assets-test.assetbank-server.com",
"RequestIdentityPath": "/assetbank-rya-assets-test/oauth/authorize",
"AuthorizationUrlRequiresRedirectUrl": true,
"RequestTokenPath": "/assetbank-rya-assets-test/oauth/token",
"RequestTokenFormat": "FormUrlEncoded",
"JsonSerializer": "SystemTextJson",
"ClientId": "",
"ClientSecret": "",
"Scopes": "",
"SampleRequest": "/assetbank-rya-assets-test/rest/asset-search?assetIds=28039"
},
{
"Alias": "github",
"DisplayName": "GitHub",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public HttpRequestMessage CreateRequestMessage<TRequest>(

requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
requestMessage.Headers.UserAgent.Add(new ProductInfoHeaderValue("UmbracoServiceIntegration", "1.0.0"));
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
return requestMessage;
}

Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.1.1",
"version": "0.1.2",
"assemblyVersion": {
"precision": "build"
},
Expand Down