I have this call that makes a client log in, but how do i pass the username and email to authenticate the user. What i am trying to do is get all the uploaded files from a particular user YouTube account. This is the client log in I am using but doesn't work:
Dim Str As System.IO.Stream
Dim srRead As System.IO.StreamReader
Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(String.Format("https://www.google.com/accounts/ClientLogin/Email={0}&Password={1}&service=youtube&source=Test", username, password))
Dim resp As System.Net.WebResponse = req.GetResponse
Str = resp.GetResponseStream
srRead = New System.IO.StreamReader(Str)
Me.XMLDocument.LoadXml(srRead.ReadToEnd)
Then when the user authenticates I need to make another request that gets the uploaded videos if the client log in is successful.
you don't need to authenticate to retrieve a user's uploads, just a simple GET request on the YouTube API will get you the data in XML:
http://gdata.youtube.com/feeds/api/users/<username>/uploads
For example, see here for all uploads by HBO Sports.
see here for how to use the YouTube .NET Client Library to retrieve the videos uploaded by a particular User:
http://code.google.com/apis/youtube/2.0/developers_guide_dotnet.html#Retrieving_Uploads
Related
I have a VBA macro in Outlook that moves a selected message into my archive folder and gets a url for the message. I also would like to add the message to Evernote like the "Save to Evernote" add-in and automatically add the url to the message as the url of the note.
I downloaded the COM setup for the Evernote Cloud SDK:
https://github.com/evernote/evernote-cloud-sdk-windows/tree/master/COM%20Setup
I then registered for and received my Evernote API Key for this application (Consumer Key and Consumer Secret).
I have an account in the sandbox.
I added a reference to the Evernote Cloud SDK and wrote some simple code to test that it is working.
However, the following code fails when checking the SharedSession.IsAuthenticated.
The code:
Public Sub CreateNote()
Const Key = "MY KEY"
Const Secret = "MY SECRET"
Const Host = "sandbox.evernote.com"
Dim evernoteSession As New ENSessionForCOM
Call evernoteSession.SetSharedSessionConsumerKey(Key, Secret, Host)
If evernoteSession.SharedSession.IsAuthenticated = False Then
evernoteSession.SharedSession.AuthenticateToEvernote
End If
End Sub
The error:
Run-time error '-2147024809 (80070057)'
Cannot create shared Evernote session without either a valid
consumer key/secret pair, or a developer token set.
I thought maybe I was trying too soon, but it has been almost 24 hours. What am I doing wrong?
After a lot of trial and error, I finally found a solution. Instead of an ENSessionForCOM, I needed to create an ENSessionAdvancedForCOM object. So now the code looks like this:
Public Sub CreateNote()
Const Key = "MY KEY"
Const Secret = "MY SECRET"
Const Host = "sandbox.evernote.com"
Dim evernoteSession As New ENSessionAdvancedForCOM
Call evernoteSession.SetSharedSessionConsumerKey(Key, Secret, Host)
If evernoteSession.SharedSession.IsAuthenticated = False Then
evernoteSession.SharedSession.AuthenticateToEvernote
End If
End Sub
And it now authenticated.
I currently have an intranet website set up using IIS. It uses Windows authentication. It looks to Active Directory to get a user's email address through the following two lines of code :
Dim userStr, userEmail As String
userStr = Page.User.Identity.Name.ToString
userEmail = System.DirectoryServices.AccountManagement.UserPrincipal.Current.EmailAddress
Then, this email is used to send an email via SMTP client. My problem is that, when my website is hosted on our server, the email address seems to be inaccessible. This code works perfectly on my localhost. I have my page set up to show the email address once it is accessed, and it just remains blank on the server.
Can anyone tell me what could be going on? It also seems that some of my events are not firing, but I think that is due to the empty email address.
Thank you
I ended up using the following code, which works:
Dim userStr, userEmail As String
userStr = Page.User.Identity.Name.ToString
Using HostingEnvironment.Impersonate()
Dim ctx As PrincipalContext = New PrincipalContext(ContextType.Domain)
Dim xUser As UserPrincipal = UserPrincipal.FindByIdentity(ctx, userStr)
userEmail = xUser.EmailAddress
End Using
It turns out the the code in the original question was trying to return the email address for the identity I am using in IIS. By using this code instead, I am able to return the current user's email address.
I am following this link to get the logged in users details and using this code snippet below
FacebookClient fb = new FacebookClient(string_access_token_here);
dynamic myInfo = fb.Get("/me")
dynamic myExtraInfo = fb.Get("/me?fields=albums.limit(5).fields(name, photos.limit(2).fields(name, picture, tags.limit(2))),posts.limit(5)");
While I get the basic details in myInfo, in my extra info variable I only end up getting an ID
I suspect I have not crafted the URL properly. Is there something else I need to do?
You need to request the user_photos permission for your access token before you can request albums/photos.
The query itself is fine:
https://developers.facebook.com/tools/explorer?method=GET&path=me%3Ffields%3Dalbums.limit(5).fields(name%2C%20photos.limit(2).fields(name%2C%20picture%2C%20tags.limit(2)))%2Cposts.limit(5)&version=v2.0
I'm using HttpWebRequest to programatically export an SSRS 2008 report in PDF format. My problem however, is my NetworkCredentials don't seem to be working. I'm receiving an Unauthorized (401) error when trying access SSRS.
I know the NetworkCredentials I supplied are correct. If I log into our SSRS web service manually, these are the exact credentials I use. Also, this works fine locally, just not up on our server.
The report is run on our asp.net 4.0 website. When the user clicks the "Generate Report" button, the following code is executed (the error occurs on my 2nd line, on WebRequest.Create) to try to connect to my SSRS 2008:
string sTargetURL = "MY_REPORT_SERVER?/REPORT_NAME&rs:format=pdf&rs:command=render&rc:parameters=Collapsed";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sTargetURL);
req.PreAuthenticate = true;
req.Credentials = new NetworkCredential("Username", "Password", "Domain");
HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse();
Stream fStream = HttpWResp.GetResponseStream();
byte[] fileBytes = ReadFully(fStream);
HttpWResp.Close();
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ContentType = "application/pdf";
System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=\"" + reportName + ".pdf"\"");
System.Web.HttpContext.Current.Response.BinaryWrite(fileBytes);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
Outside the application, are you able to run the report locally and in the Report Manager/Server? If so, what type of data source does the report use? It could be that the data source does not accept the credentials double-hopping from the Report Server. You may need to create a domain account with the necessary read rights and configure the data source on the Report Server to impersonate these credentials.
I'm using Facebook SDK 6 and Graph API to publish data from app (ASP.NET) to the page.
Firstly, my app (website) get access token using server flow as described here.
Next, it use this token to publish some text in my page:
Dim fb = New FacebookClient(accessToken)
Dim o As Dictionary(Of String, Object) = New Dictionary(Of String, Object)
o.Add("message", "some text...")
Dim result = fb.Post("/TfdTest/feed", o)
To test it, I browse my website. I allow my site change my facebook page and give permissions (publish_stream, manage_pages). The problem is that final feed appears in "Recent Posts by Others" section:
How can I post feed from page name, not from myself???
in order to use Graph API on behalf of a Page, you need to get Page access token - see here for more details: https://developers.facebook.com/docs/authentication/pages/
Authenticate the user and request the manage_pages permission
Get the list of pages the user manages using token from (1) - https://graph.facebook.com/me/accounts?access_token=USER_ACCESS_TOKEN
Parse the list and get the PAGE token - and use it to post to the feed.