diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5de087d..9dc805b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,11 +50,6 @@ jobs: id: gitversion uses: gittools/actions/gitversion/execute@v0.9.4 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.301 - - name: Setup Java JDK uses: actions/setup-java@v1 with: @@ -157,4 +152,4 @@ jobs: - name: Push to NuGet run: dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_AUTH_TOKEN}} .\artifacts\**\*.nupkg --skip-duplicate --no-symbols true env: - DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLE: false \ No newline at end of file + DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLE: false \ No newline at end of file diff --git a/Imgur.API.sln b/Imgur.API.sln index b41b268..f1cc6d5 100644 --- a/Imgur.API.sln +++ b/Imgur.API.sln @@ -11,11 +11,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{95D79228 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Imgur.API.Tests", "tests\Imgur.API.Tests\Imgur.API.Tests.csproj", "{65F14BBA-B4B5-4243-823A-4FAF41AB67BD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Imgur.API.Tests.Integration", "tests\Imgur.API.Tests.Integration\Imgur.API.Tests.Integration\Imgur.API.Tests.Integration.csproj", "{4AD6F734-769C-437F-88BC-75727427F210}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Imgur.API.Tests.Integration", "tests\Imgur.API.Tests.Integration\Imgur.API.Tests.Integration\Imgur.API.Tests.Integration.csproj", "{4AD6F734-769C-437F-88BC-75727427F210}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D42AD5DE-ED8F-42B5-A22D-4AC6B811DF95}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig + README.md = README.md EndProjectSection EndProject Global diff --git a/README.md b/README.md index b1de8a4..3e9a812 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # Imgur.API Imgur.API is a .NET implementation of Imgur's API. -It supports Imgur's free and RapidAPI's commercial API endpoints. - ![Build](https://github.com/DamienDennehy/Imgur.API/workflows/Build/badge.svg) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ImgurAPI&metric=alert_status)](https://sonarcloud.io/dashboard?id=ImgurAPI) @@ -10,7 +8,6 @@ It supports Imgur's free and RapidAPI's commercial API endpoints. [![NuGet](https://img.shields.io/nuget/vpre/Imgur.API.svg)](https://www.nuget.org/packages/Imgur.API/) ## Getting Started - ### Register Client Register your App at https://api.imgur.com/oauth2/addclient @@ -20,9 +17,47 @@ var apiClient = new ApiClient("YOUR_CLIENT_KEY"); ~~~ ## Using OAuth +### Getting an Authorization Url +The Authorization Url should be loaded in a browser, allowing the user to login to Imgur. + +~~~ +var apiClient = new ApiClient("YOUR_CLIENT_KEY", "YOUR_CLIENT_SECRET"); +var httpClient = new HttpClient(); + +var oAuth2Endpoint = new OAuth2Endpoint(apiClient, httpClient); +var authUrl = oAuth2Endpoint.GetAuthorizationUrl(); +~~~ + +Once user has logged in, they are redirected to your previously set Url. +Once the token information is available and parsed create a token. + +~~~ +var token = new OAuth2Token +{ + AccessToken = "YOUR_TOKEN", + RefreshToken = "YOUR_REFRESH_TOKEN", + AccountId = YOUR_ACCOUNT_ID, + AccountUsername = "YOUR_ACCOUNT_PASSWORD", + ExpiresIn = YOUR_EXPIRATION, + TokenType = "YOUR_TOKEN" +}; +~~~ + +Then set the token on the ApiClient. + +~~~ +apiClient.SetOAuth2Token(token); +~~~ + +Continue to use the rest of the Endpoints. + +~~~ +var imageEndpoint = new ImageEndpoint(apiClient, httpClient); +~~~ ## Uploading Images & Video ### Uploading Image + ~~~ var apiClient = new ApiClient("YOUR_CLIENT_KEY"); var httpClient = new HttpClient(); @@ -32,8 +67,10 @@ using var fileStream = File.OpenRead(filePath); var imageEndpoint = new ImageEndpoint(apiClient, httpClient); var imageUpload = await imageEndpoint.UploadImageAsync(fileStream); -~~~ +~~~ + ### Uploading Video + ~~~ var apiClient = new ApiClient("YOUR_CLIENT_KEY"); var httpClient = new HttpClient(); @@ -43,8 +80,10 @@ using var fileStream = File.OpenRead(filePath); var imageEndpoint = new ImageEndpoint(apiClient, httpClient); var imageUpload = await imageEndpoint.UploadVideoAsync(fileStream); -~~~ +~~~ + ### Uploading Video with Progress + ~~~ var apiClient = new ApiClient("YOUR_CLIENT_KEY"); var httpClient = new HttpClient(); @@ -61,11 +100,8 @@ void report(int byteProgress) { //Do something with the progress here. } -~~~ +~~~ ## API Definition -As of August 2020 two Endpoints are available: -* OAuthEndpoint -* ImageEndpoint - -The methods on the endpoints match what is available at the official Imgur API at https://apidocs.imgur.com/ \ No newline at end of file +Several Endpoints are available. +The methods on the Endpoints match what is available at the official Imgur API at https://apidocs.imgur.com/ \ No newline at end of file diff --git a/src/Imgur.API/Imgur.API.csproj b/src/Imgur.API/Imgur.API.csproj index 163e9a3..b731dc7 100644 --- a/src/Imgur.API/Imgur.API.csproj +++ b/src/Imgur.API/Imgur.API.csproj @@ -5,6 +5,9 @@ true https://github.com/DamienDennehy/Imgur.API icon.png + LICENSE + Imgur.API is a .NET implementation of Imgur's API. + imgur;media;image;video;upload @@ -17,6 +20,7 @@ +