{"id":30420850,"url":"https://github.com/abjerner/skybrud.social.instagram","last_synced_at":"2025-08-22T08:20:45.537Z","repository":{"id":146308830,"uuid":"48859655","full_name":"abjerner/Skybrud.Social.Instagram","owner":"abjerner","description":" .NET wrapper and API implementation for the Instagram Basic Display API and Instagram Graph API.","archived":false,"fork":false,"pushed_at":"2024-03-02T22:24:31.000Z","size":4922,"stargazers_count":13,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"v1/main","last_synced_at":"2025-08-01T01:46:12.970Z","etag":null,"topics":["api","api-wrapper","authentication","csharp","dotnet","instagram","instagram-api","instagram-basic-display-api","instagram-graph-api","limbo","oauth","oauth2","package","skybrud","skybrud-integrations","skybrud-social"],"latest_commit_sha":null,"homepage":"https://packages.limbo.works/skybrud.social.instagram/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abjerner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-12-31T19:09:13.000Z","updated_at":"2024-07-07T12:26:52.000Z","dependencies_parsed_at":"2024-02-29T23:47:18.318Z","dependency_job_id":null,"html_url":"https://github.com/abjerner/Skybrud.Social.Instagram","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/abjerner/Skybrud.Social.Instagram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abjerner%2FSkybrud.Social.Instagram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abjerner%2FSkybrud.Social.Instagram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abjerner%2FSkybrud.Social.Instagram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abjerner%2FSkybrud.Social.Instagram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abjerner","download_url":"https://codeload.github.com/abjerner/Skybrud.Social.Instagram/tar.gz/refs/heads/v1/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abjerner%2FSkybrud.Social.Instagram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271606605,"owners_count":24788981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-wrapper","authentication","csharp","dotnet","instagram","instagram-api","instagram-basic-display-api","instagram-graph-api","limbo","oauth","oauth2","package","skybrud","skybrud-integrations","skybrud-social"],"created_at":"2025-08-22T08:20:35.710Z","updated_at":"2025-08-22T08:20:45.530Z","avatar_url":"https://github.com/abjerner.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Skybrud.Social.Instagram\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/abjerner/Skybrud.Social.Instagram/blob/v1/main/LICENSE.md)\n[![NuGet](https://img.shields.io/nuget/v/Skybrud.Social.Instagram.svg)](https://www.nuget.org/packages/Skybrud.Social.Instagram)\n[![NuGet](https://img.shields.io/nuget/dt/Skybrud.Social.Instagram.svg)](https://www.nuget.org/packages/Skybrud.Social.Instagram)\n\n**Skybrud.Social.Instagram** is a .NET wrapper and API implementation for the [**Instagram Basic Display API**](https://developers.facebook.com/docs/instagram-basic-display-api) and [**Instagram Graph API**](https://developers.facebook.com/docs/instagram-api).\n\nThe package helps handling some of the underlying authentication as well as communicating with both APIs in a strongly typed way.\n\n\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n### Target Frameworks\n\n.NET Standard 1.3, .NET Standard 2.0 and .NET 7 ([read more](https://www.nuget.org/packages/Skybrud.Social.Instagram#supportedframeworks-body-tab)).\n\n\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n### Installation\n\nInstall the \u003ca href=\"https://www.nuget.org/packages/Skybrud.Social.Instagram/1.0.0-beta008\" target=\"_blank\"\u003eNuGet package\u003c/a\u003e - either via the .NET CLI:\n\n```\ndotnet add package Skybrud.Social.Instagram --version 1.0.0-beta008\n```\n\nor the NuGet package manager:\n\n```\nInstall-Package Skybrud.Social.Instagram -Version 1.0.0-beta008\n```\n\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n### Found a bug? Have a question?\n\n* Please feel free to [**create an issue**][Issues], and I will get back to you ;)\n\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n### Changelog\n\nThe [**releases page**][Releases] lists all releases, and each there will be some information for each release on the most significant changes.\n\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n### Documentation\n\nYou can find documentation and examples on how to use this package at the [**Skybrud.Social website**][Website].\n\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n#### Usage\n\n##### Initializing a new OAuth client\n\nThe `InstagramOAuthClient` class is responsible for the raw communication with the Instagram API as well as authentication using OAuth 2.0. The class can be initialized with one of the constructors, or simply by setting the properties like in the examples below:\n\n```C#\n// Initialize and configure the OAuth client\nInstagramOAuthClient client = new InstagramOAuthClient {\n    AccessToken = \"Insert your access token here\"\n};\n```\n\nor:\n\n```C#\n// Initialize and configure the OAuth client\nInstagramOAuthClient client = new InstagramOAuthClient {\n    ClientId = \"Insert your client ID here\",\n    ClientSecret = \"Insert your client secret here\",\n    RedirectUri = \"http://social.abjerner/instagram/oauth\"\n};\n```\n\nAuthentication requires that you specify the client ID, client secret and redirect URI of your app (client).\n\n* [**Register a new client** *at www.instagram.com*](https://www.instagram.com/developer/clients/register/)\n* [**Manage existing clients** *at www.instagram.com*](https://www.instagram.com/developer/clients/manage/)\n\n\n##### Generating the authorization URL / getting an authorization code\n\nTo start authenticating the user, you should generate and redirect the user to the authorization URL. The authorization URL is constructed of the client ID and redirect URI of the OAuth client as well as a state (random value for security purposes) and the scope (permissions) which your user should grant your app.\n\nIf you just need an authorization URL with the default scope, your code could look like:\n\n```C#\n// Generate the authorization URL (with default scope)\nstring authorizationUrl = client.GetAuthorizationUrl(state);\n```\n\nIf you instead need the `basic` (granted by default) and `public_content` scopes, your code could look like:\n\n```C#\n// Generate the authorization URL\nstring authorizationUrl = client.GetAuthorizationUrl(state, InstagramScopes.Basic + InstagramScopes.PublicContent);\n```\n\nWhen the user is redirected to the authentication URL, he/she will be prompted to accept the scope that you have specified.\n\n\n\n\n\n##### Obtaining an access token\n\nThe access token can be obtained using the `GetAccessTokenFromAuthCode` method, where the response body will reveil the access token as well information about the authenticated user.\n\nFor the example below, the `authCode` parameter is the authorization code received when the user has succesfully logged in through the Windows Live login dialog, and been redirected back to your site. At this point, the `code` parameter in the query string will contain the authorization code.\n\n```C#\n// Exchange the authorization code for an access token\nInstagramTokenResponse response = client.GetAccessTokenFromAuthCode(authCode);\n\n// Get the access token from the response body\nstring accessToken = response.Body.AccessToken;\n```\n\n\n\n\n\n##### Initializing an instance of InstagramService\n\nOnce you have obtained an access token, you can initialize a new instance of the `InstagramService` class as shown in the exampel below:\n\n```C#\n// Initialize a new service instance from an access token\nInstagramService service = InstagramService.CreateFromAccessToken(\"Insert your access token here\");\n```\n\nThe `InstagramService` class serves as your starting point to making calls to the Instagram API.\n\n\n\n##### Complete example\n\nIn the example below, I've tried to demonstrate how a login page can be implemented (involving the steps explained above).\n\nNotice that the example generates a `state` that is saved to the user's session. When redirecting the user to Instagram's authentication page, we supply the state, and once the user completes (or cancels) the authentication, the same `state` is specified in the URL the user is redirected back to (at your site). We can then check whether the `state` is saved in the user session to make sure it's still the same user making the request.\n\n```C#\n@using Skybrud.Social.Instagram.OAuth\n@using Skybrud.Social.Instagram.Responses.Authentication\n@using Skybrud.Social.Instagram.Scopes\n\n@{\n\n    // Initialize a new OAuth client with the information from your app\n    InstagramOAuthClient client = new InstagramOAuthClient {\n        ClientId = \"Your client ID\",\n        ClientSecret = \"Your client secret\",\n        RedirectUri = \"http://social.abjerner/instagram/oauth/\"\n    };\n\n    if (Request.QueryString[\"do\"] == \"login\") {\n\n        // Generate a random scope\n        string state = Guid.NewGuid().ToString();\n\n        // Generate the session key for the state\n        string stateKey = \"InstagramOAuthState_\" + state;\n\n        // Store the state in the session of the user\n        Session[stateKey] = Request.RawUrl;\n\n        // Generate the authorization URL\n        string authorizationUrl = client.GetAuthorizationUrl(state, InstagramScopes.PublicContent);\n\n        // Redirect the user\n        Response.Redirect(authorizationUrl);\n\n    } else if (Request.QueryString[\"code\"] != null) {\n\n        // Get the state from the query string\n        string state = Request.QueryString[\"state\"];\n\n        // Get the code from the query string\n        string code = Request.QueryString[\"code\"];\n\n        // Generate the session key for the state\n        string stateKey = \"InstagramOAuthState_\" + state;\n\n        if (Session[stateKey] == null) {\n            \u003cp\u003eHas your session expired?\u003c/p\u003e\n            \u003cp\u003e\n                \u003ca class=\"btn btn-default\" href=\"/instagram/oauth?do=login\"\u003eRe-try login\u003c/a\u003e\n            \u003c/p\u003e\n            return;\n        }\n\n        InstagramTokenResponse response = client.GetAccessTokenFromAuthCode(code);\n\n        \u003cdiv class=\"box\"\u003e\n            \u003cp\u003eHi \u003cstrong\u003e@(response.Body.User.FullName ?? response.Body.User.Username)\u003c/strong\u003e\u003c/p\u003e\n            \u003cp\u003eId: @response.Body.User.Id\u003c/p\u003e\n            \u003cp\u003eUsername: @response.Body.User.Username\u003c/p\u003e\n            @if (!String.IsNullOrWhiteSpace(response.Body.User.ProfilePicture)) {\n                \u003cimg src=\"@response.Body.User.ProfilePicture\" /\u003e\n            }\n        \u003c/div\u003e\n\n        \u003cbr /\u003e\n\n        \u003cdiv\u003eAccess Token:\u003c/div\u003e\n        \u003cpre\u003e@response.Body.AccessToken\u003c/pre\u003e\n\n        return;\n\n    }\n\n    \u003cp\u003e\n        \u003ca class=\"btn btn-default\" href=\"/instagram/oauth?do=login\"\u003eLogin with Instagram\u003c/a\u003e\n    \u003c/p\u003e\n\n}\n```\n\n\n\n\n\n[Website]: http://social.skybrud.dk/instagram/\n[NuGetPackage]: https://www.nuget.org/packages/Skybrud.Social.Instagram\n[GitHubRelease]: https://github.com/abjerner/Skybrud.Social.Instagram/releases/latest\n[Releases]: https://github.com/abjerner/Skybrud.Social.Instagram/releases\n[Issues]: https://github.com/abjerner/Skybrud.Social.Instagram/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabjerner%2Fskybrud.social.instagram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabjerner%2Fskybrud.social.instagram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabjerner%2Fskybrud.social.instagram/lists"}