InstaSharp authentication without user interaction - c#

I'm trying to write a service, that can get the Instagram feed for a specific user.
Im using InstaSharp, but I can't figure out how to do the authentication without redirecting the end user to a https://api.instagram.com/oauth/authorize url
I can't find any examples, beside this (and others looking like it)
Can anyone give me any pointers.
For now I have a Instagram app in sandbox mode, and a selection of users, who have accepted the sandbox invite.

I don't think it's possible with this library. You better generate your access token by yourself - https://elfsight.com/blog/2016/05/how-to-get-instagram-access-token/ and then request user's feed as like this
https://api.instagram.com/v1/users/{USER-ID}/media/recent/?access_token={YOUR-ACCESS-TOKEN}
If you want to deserialize your JSON object to c#, please use this service - http://json2csharp.com for generating your class and then using Newtownsoft library:
JsonConvert.DeserializeObject<RootObject>(yourClass)
Good luck.

Related

How to access XML file on employee sharepoint portal?

Body
Hi guys. I'll be rather brief if I can so here goes.
I made this app in C# that goes onto my employee portal and automatically gets my shifts for me every 30 minutes my using a web browser control and then it reads the HTML data from that and generates a calendar for me and also provides automated alerts.
Issue
Problem is that this web browser uses IE (yeesh help me) and it doesn't work with all parts of the site. I have done some digging around on the site and I found where the ASP site gets the data from: An XML sheet somewhere on the server. I can access this XML sheet, but only if I'm logged in (please see the attached images for more information).
Current solution
So my question is this: How do I actually login to this area?
I could login using the webbrowser and then download the XML using that, but it's too slow and too old, so is there a way I can pass my credentials through?
The URL is like this "https://www.mycoles.com.au/api/rosters/nextweek" -- I don't see any thing like ?name=myname ?pass=mypassword... soo yea. (I'm a bit new).
Further details:
Application language: C#.
Current technology: Windows forms applications/ IE web browser control.
Site backend: Microsoft Sharepoint.
Anything I'm missing? Please ask..?
Attached content
Mycoles XML Logged in
Mycoles XML Access Denied
Update:
So after a while of searching and examining the site, I tried to access the data with a c# webbrowser and it didn't work. It said that it can't download the data, however chrome is able to. Odd. I'm not sure it is an XML file anymore, rather a request and I don't have enough knowledge to work with this, so pointers anyone? Check this site out https://www.mycoles.com.au/api/rosters/nextweek and tell me what you think it is please. Thanks in advance... :)
SharePoint supports different forms of authentication. Out of the box, Active Directory-based single sign-on is provided, and forms-based (username, password) authentication can be configured.
Typically, organizations use AD SSO for its simplicity. If, once you open your desktop browser and navigate to a SharePoint site, you don't have to enter any credentials and are just logged in, then it's most likely this case. This can be either Kerberos or NTLM. The HttpWebRequest class supports both these methods.

Prevent unwanted access to my web service

I have coded a C# MVC5 Internet application and I have a Web API 2 web service that returns JSON data. I am retrieving this JSON data in an android application.
How can I add a feature to the web service such that only my android application can retrieve the JSON data? I am wanting to do this so that other web users cannot hammer the url and the web service will not send my data to unwanted applications and/or users.
Is this possible? If so, how should I do this?
Thanks in advance.
You have various ways to achieve this in fact.
For example, you can store a key in your android application and use send this key together with the request to your WebAPI. Your webAPI will than check if they key is valid and if it is, it will return the JSon.
However, there's no way to ensure that nobody else can request and get your data. For example by reverse engineering your android application and extracting the key, or by monitoring the network traffic and find the key in there.
You need to understand that there isn't anthing that guarantuees you 100% security.
See it as the following:
You have an open door right now, you can close it little by little, but closing and locking down is not possible. There will always be gap. A house also can't by made burglar proof, but you can make it very hard for a buglar to enter.
Go to this link Web Api. I have used the individual authentication for my web api. When you will register the user the response you will get is access token and use that access token as Authentication header in your ajax call if you are using Jquery ajax to call your Web Api. Refer this The OAuth 2.0 Authorization Framework. Hope this help you.
Are you looking for something like this?
http://httpd.apache.org/docs/2.2/howto/access.html
If you have other web server, there should be appropriate means to support such.

Grabbing facebook stats with a c# app

I have found many examples of getting data from facebook manually.
Is there a way to grab the data using an application (not a web app)?
What we are doing is creating a data repository for our customers so they can look at their data from FB, GA, twitter ect all in one place.
Facebook has me stuck as I can get an authentication code, but none of the URLs such as https://graph.facebook.com/me/friends?access_token=... will work. Guessing because "me" means I need to be logged into my site for it to work.
Any help/examples would be great.
Thank You

How to access friends album in Facebook

I am developing a Facebook application, where my application will aggregate all the photos of my friends in their albums. How will i achieve using graph api and C#?
First, look at this answer: Can I use the Facebook graph api to get user's friends profiles pictures ?
This will let you know how to generally use the graph api to get the to the friends. If you use albums instead of photo, you should get all the albums of a friend.
To get there, you will also need the friends_photos permission. I don't know if it is still up to date, but maybe you will need some more permissions.
I'm no C# developer, but these links will help you:
C# Facebook Graph API Library
Facebook C# SDK
Facebook API from C# – Getting the list of friends
Facebook recently made a nice tool you can use to explore how to get the details you need. It's called the Graph API Explorer and can be found here: https://developers.facebook.com/tools/explorer
But what is said in the other answer is correct. First you get the list of friends. Then their albums, and then the photos in the albums. Once you get the hang of the Graph API it's quite easy, but it requires a bit of tinkering to figure out at first.
If you are using C# you can use a WebRequest to get the data. Whenever you access http://graph.facebook.com/whateveryouwant it will return a string of JSON-data. This you can parse using a JSON-librabry like litJSON.
I have made an application that gets the profile photos, and it is not that hard. Just remember to get the right permissions.
The easiest way to do this is to use the Javascript API to get the loginstatus and then get some permissions. If you set cookies: true when you init the Facebook API you can get the accesss_token from the cookie. The cookie is named "fbs_YOURAPPID".
Also you need to make a developer app to get an access_token.

Authenticate on an ASP.Net Forms Authorization website from a console app

I'm trying to build a C# console application to automate grabbing certain files from our website, mostly to save myself clicks and - frankly - just to have done it. But I've hit a snag that for which I've been unable to find a working solution.
The website I'm trying to which I'm trying to connect uses ASP.Net forms authorization, and I cannot figure out how to authenticate myself with it. This application is a complete hack so I can hard code my username and password or any other needed auth info, and the solution itself doesn't need to be something that is viable enough to release to general users. In other words, if the only possible solution is a hack, I'm fine with that.
Basically, I'm trying to use HttpWebRequest to pull the site that has the list of files, iterating through that list and then downloading what I need. So the actual work on the site is fairly trivial once I can get the website to consider me authorized.
I have dealt with something similar, and the hardest part is figuring out exactly what you needed to "fake" to get authorized. In my case it was authorizing into some Lotus Notes webservice, but the details are unimportant, the method is the same.
Essentially, we need to record a regular user session. I would recommend Fiddler http://www.fiddler2.com but if you're on linux or something, then you'll need to use wireshark to figure some of the things out. Not sure if there is a firefox plugin that could be used.
Anyway, start up IE, then start up Fiddler. Complete the login process.
Stop what you're doing. Switch to the fiddler pane, and examine the recorded sessions in detail. It should give you exactly what you need to fake using WebRequests.
This page should get you started. You need to first make a request to the page, and then saving the cookie to a container that you include in all later request. That should keep you logged in, and able to retrieve the files.

Categories

Resources