401 Authentication issue using twitter api with Get Method (oAuth) - asp.net

I want to search microblogs from twitter using
http://api.twitter.com/1/users/search.xml
using following header to authenticate the request.
{Authorization: OAuth oauth_nonce="NjM0NTU3NjkwODQ1NjI1MDAw",
oauth_signature_method="HMAC-SHA1",oauth_timestamp="1320201086",
oauth_consumer_key="Key Goes Here",
oauth_token="Token goes here",
oauth_signature="D%2FEWfy3qEr5QiEzSvtcYhBDs864%3D",
oauth_version="1.0"
}
but it give me 401 Authentication failed.
Can anybody help me to get out of this.

I would suggest you look into using a pre-made library to handle the Twitter API calls, or, at the very least, OAuth.
In my opinion, it will not be worth your time to work through the many steps required for OAuth request signing.
There are many libraries available (list swiped from dev.twitter.com with inactive projects omitted):
DotNetOpenAuth
Hammock
LINQ to Twitter
OAuth-Dot-Net
Twitterizer
Full disclosure: I am the author of Twitterizer.

Related

How to get OAuth token in Business Central Codeunit (al code)

We have been searching and searching to find examples of how to get an OAuth token in al code in our codeunit. We can successfully get the token in Postman, so I know all the credentials are correct. But finding examples on the web of how to do this has proven to be extremely difficult.
I did find this .al page from Microsoft that looks like it has an example using OAuth2.AcquireTokenWithClientCredentials but we can't get it to work. https://github.com/microsoft/BCTech/blob/master/samples/OAuth2Flows/TestOAuth2Flows.Page.al
Does anyone have a working example of this?
Kauffmann has a good blog post on this. It's talking about calling BC with an OAuth token, but the same principle applies.
Are you able to get the OAuth token in AL, and just have trouble using it to authenticate the request? If so, try this from the blog post:
Client.DefaultRequestHeaders.Add('Authorization', GetAuthenticationHeaderValue(AccessToken));
Client.DefaultRequestHeaders.Add('Accept', 'application/json');
If you can't get the token, I'd recommend looking at the OAuth2 codeunit.

403 Forbidden "These credentials do not authorize access" for HERE Geocoding & Search API

Currently working on building an address validator for a project I am working on, currently using a HERE account with a credit card attached for usage with the HERE Geocoding and Search API.
A minimal example to get started, a request to https://geocode.search.hereapi.com/v1/geocode?q=eiffel+tower&apiKey={{apikey}} is returning the following;
{
"error": "Forbidden",
"error_description": "These credentials do not authorize access"
}
I've confirmed the API key to be functional, as a request to the older API, like so https://geocoder.ls.hereapi.com/search/6.2/geocode.json?searchtext=eiffel+tower&apiKey={{apikey}} does work and returns expected results.
I'd like to use this API specifically, as it will be interfacing with a system that uses this version of the HERE API, and would like to maintain parity.
The documentation states that either API Key or OAuth are acceptable to use, and according to the linked identity & access management guide, this is done by simply adding the apikey query parameter, as seen in the working 6.2 example.
Other questions on the matter state that this code is returned when the endpoint is not usable on a base plan, however the pricing page indicates this should be usable on a free account up to 5000 requests.
You have linked your app_id, which are using is linked to as specific project.Because of this you are not able to use this app_id in the geocode service.
Please make sure that the app is linked to No project in the access manager as shown in the below screen.

3rd party cookies & Google OAUTH

I started working on server side for my current porject and one of the biggest issues that i facing is with Google O-Auth. Since i am not experienced with the server i decided to use firebase throughout my project.
3rd party cookies are need to be enabled for Google OAuth. I am trying to find my way around it(means: even if the 3rd party cookies are disabled a user can login through google).
First Qestion: Is it even possible?..
i guess it is because i have tried few popular websites like bitbukcet where even if you switch off 3rd party cookies, the O auth works perfectly.
If yes then Second Question: How do i implement it? i was reading some Google Developer docs and found this "another workaround is to implement server-side OAuth 2.0 flows". I really do not understand this.
What i have tried:
I have tried two things, first the typical and easier way of going with firebase auth and google login with popup. Second, Login through GAPI AUTH.
I am looking forward to any answer.
You can look at this link for an overview on how to implement server side based Oauth2 flow for Google. Please ignore the bits which are youtube specific but the instructions should apply to any google auth flow.
Basically you do not need to include any client side JS files on your webpage etc since they don't work with 3p cookies blocked. The server side flow is free from that restriction.
Edit: Adding a more general link for server side Oauth2 flow

Facebook API Auto accept friend request

I've created a web application that uses the Facebook API.
I would like to implement/create a method which is able to auto accept friend request of my own Facebook account.
Is this even possible and how to implement it in C#/ ASP.NET MVC?
Thank you in advance!
*I alreay read the Facebook Developers documentation https://developers.facebook.com/docs/howtos/requests/ but haven't been able to solve my 'problem'.
There is no API to send or approve friend requests.
There is the Friends Dialog but it sounds like you want this to work without user interaction which is impossible.
If you find some way to do this, you should report it via Facebook's whitehat bug bounty program, as it indicates a bug on Facebook's side.

How to connect Facebook, Twitter & Google accounts in Java (Spring MVC)

I'm going through the features of social auth (http://code.google.com/p/socialauth/) & wondering if this is the best thing for my requirement. Please guide.
My web application currently has it's own login mechanism(native). But I'm planning to do the following:
Login through Facebook(F), Twitter(T) and Google(G) options
After login (either through F,T,G or native login), I want to give user the option of selecting F friends, T followers or G contacts (in a textbox with autosuggest facility)
So my doubt is: (social auth says that "..currently Facebook, Twitter and LinkedIn do not provide email addresses. UPDATE: Hotmail has stopped providing email addresses.")
So although I'll have a list of followers, friends or contacts will I be able to notify them once my user selects and submits his form?
Will it be through F,T or G respectively(through status updates, tweets or email?)
Moreover, I've one more scenario:
E.g. the user has logged in using Facebook. Now I want the user to be able to link her Twitter and Google account too. Can socialauth provide that?
If yes, how would I handle multiple profile objects of the same user?
Please guide or suggest any other library.
My application is in Spring MVC.
Or shall I use Spring Social?
Since your application uses Spring-MVC you should try Spring Social. It would be best for your application.
You can also use socialauth library. It also has spring version to connect with FB, twitter and others provider. Link for the same is as given below:-
http://code.google.com/p/socialauth/
Spring Social is best option for your requirement and in can be easily integrated with
There are 2 proven ways which can be used for this
Using Spring-security-oauth2
Using Spring Social
However, if you are using just Spring Social based on the facebook example, provided on the Spring Website then be mindful of these issues
It doesn't work for more than 1 user
Spring-social doesn't support Google either.
It is also difficult to change the redirect flow unless you override the methods
But the good thing is there are workarounds to fix them and they are quite simple.
Here is how to fix FB one user per application problem
For connecting/authenticating with Google
For Changing the default redirect flow
The Complete tutorial with step by step instructions can be found here
Having explored both oauth2 and Spring Social. I would suggest Spring-social as its lot more simpler and custom built for social logins only.

Resources