Instagram Access Token Windows Store App C#

0

I want to get access token from instagram api in windows store app

Here's my code:

string endURL = "ms-app://..";  string clientID = "..";
Uri endUri = new Uri(endURL);
string startURL = "https://api.instagram.com/oauth/authorize/?"
                + "client_id=" + clientID
                + "&redirect_uri=" + endURL
                + "&response_type=code";
try
{
    WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync
        (WebAuthenticationOptions.None, startUri);
    if (result.ResponseStatus == WebAuthenticationStatus.Success) {
        string token = webAuthenticationResult.ResponseData;
}
catch(Exception) { }

I get that error:

The specified protocol is unknown. (Exception from HRESULT: 0x800C000D)

c#
windows-store-apps
windows-store
instagram-api
asked on Stack Overflow Feb 1, 2015 by Ghanem • edited Feb 2, 2015 by Ghanem

1 Answer

0

Why don't you directly use InstaAPI github & codeplex?


List<Scope> scopes = new List<Scope>() { Scope.basic };
InstaConfig config = new InstaConfig("CLIENT_ID", "CLIENT_SECRET", "REDIRECT_URI", scopes);

// use this to redirect user for authenticating your application
String AuthenticationUriString = config.GetAuthenticationUriString(); 

OAuth oauth = new OAuth(config, "CODE_ATTACHED_WITH_REDIRECTEDURI_AFTERSUCCESSFUL_AUTHENTICATION");
AuthUser user = oauth.GetAuhtorisedUser();

Console.WriteLine(user.AccessToken);
answered on Stack Overflow Feb 25, 2015 by Yuvraj Singh Babrah

User contributions licensed under CC BY-SA 3.0