spring-social-vkontakte problems with authorizationCode - oauth-2.0

I try to develop an application with connection to social set vkontakte. To do this I use spring-social-vkontakte module of spring-social from https:// github.com/vkolodrevskiy/spring-social-vkontakte as this resources is mentioned in official site spring social http:// www.springsource.org/spring-social.
Problem is that when I use VKontakteConnectionFactory to make request to my application in vkontakte I can't use my local address in redirect_uri because I receive na error:
{"error":"invalid_request","error_description":"redirect_uri has wrong domain, check application settings"}
in vkontakte documentation http://vk.com/developers.php?oid=-17680044&p=Authorizing_Client_Applications in section how to build authorization url is described: "REDIRECT_URI – the address to which access_token will be rendered". To resole this problem I use http:// api.vkontakte.ru/blank.html as redirect_uri, I can receive an code but after authorization I can't back to my application. It is a problem. My example:
VKontakteConnectionFactory vKontakteConnectionFactory = new VKontakteConnectionFactory(app_id, app_secret);
OAuth2Operations operations = vKontakteConnectionFactory.getOAuthOperations();
OAuth2Parameters parameters = new OAuth2Parameters();
parameters.setRedirectUri("http://api.vkontakte.ru/blank.html");
String authorazeUrl = operations.buildAuthorizeUrl(GrantType.AUTHORIZATION_CODE, parameters);
response.sendRedirect(authorazeUrl);
In vkontakte I have created on application with next parameter:
Site address: http://localhost:8080/
Base domain: localhost (in this place I can't type localhost:8080, service denies it)
I destroyed some links because I can't post so many(
If somebody knows how to do redirection to localhost or some other solution how to solve this problem, please help me.
Thanks in advance

It does not allow you to specify domain 'localhost'. It should be a kind of 'localhost.ua', 'www.mysite.com'.
This has worked for me.

I am contributor of this project and updated its wiki https://github.com/vkolodrevskiy/spring-social-vkontakte/wiki

Related

Facebook Graph API and Docker

Im working on a website using Laravel in a Docker container on local. The webserver used is Nginx.
Im trying to implement Facebook's Graph API (the PHP API) and as Im developing on localhost and using Docker, any time I want to use the API I get:
Can't Load URL: The domain of this URL isn't included in the app's
domains. To be able to load this URL, add all domains and subdomains
of your app to the App Domains field in your app settings.
I tried adding the domain I use locally myapp.local:3000, also <my ip>:3000 or localhost:3000 but nothing works.
Here is the code:
public function facebookRequest() {
$fb = new \Facebook\Facebook([
'app_id' => 'MY_APP_ID',
'app_secret' => 'MY_APP_SECRET',
'default_graph_version' => 'v8.0',
]);
$callback = 'users/get-facebook-photos';
$helper = $fb->getRedirectLoginHelper();
$permissions = ['user_photos'];
$data['fb_url'] = $helper->getLoginUrl($callback, $permissions);
$loginUrl = $helper->getLoginUrl(base_url().'/users/get-facebook-photos', $permissions);
echo 'Log in with Facebook!';
}
What I need to do to develop using Graph API and Docker? There's some option to bypass domain filter or what should I do?
Seems like you're using your application to request a token from facebook servers and when the token is created, you'll end up being redirected on to the original destination. The redirect location cannot be "localhost" it should be a valid location ... like a website. If you want to make this work locally you could edit your /etc/hosts file to map local.example.com to 127.0.0.1 and use this domain for redirections in tests/QA, so that when your app gets redirected, it attempts it via the localhost.
Another suggestion (found by searching for the exact but more generic parts of the error "Can't Load URL: The domain of this URL isn't included in the app's domains") suggests:
add "https://apps.facebook.com/" in valid OAuth redirect URIs under https://developers.facebook.com/apps/your-app-id/fb-login/settings/
Well finally got a solution (not the one I wanted). I was using a custom domain defined on my host file. That didn't work for Facebook. I needed to use localhost (not even 127.0.0.1) and whitelist localhost on Facebook Developers.
So, if you have this issue, you can do this workaround and use localhost instead of custom domain. Nevertheless, my ideal solution would be using custom domains.

AWS API Gateway {"error": "missing authentication token"}

I've been constantly getting the "missing authentication token" error when I click the AWS API gateway POST method url through the browser. I set "AUTH" as none and it's working totally fine through Postman but not with the browser. The problem is that I'm using swift to trigger the method and it doesn't seem to be reaching the gateway at all (no log on CloudWatch) and I don't think my code is wrong (or maybe it is). If someone could point out what my mistake is or a solution to this problem I'd appreciate it so much.
P.S. My lambda function is working totally fine and I typed in the right URL (one in the code is just for example)
Here's my code:
func postNonceToServer(paymentMethodNonce: String) {
let paymentURL = URL(string: "https://example-url.us-east-1.amazonaws.com/prod/create-transaction")!
var request = URLRequest(url: paymentURL)
request.httpBody = "\(paymentMethodNonce)".data(using: String.Encoding.utf8)
request.httpMethod = "POST"
}
In my opinion, this should be a problem in the URL itself. I can think of:
1- Please make sure that the URL is parsed correctly by printing it to the console and pasting it into the browser URL bar. (I have no idea about swift)
2- Make sure that "execute-api" is included in your "example-url", i.e., before the region.
3- Make sure that OPTIONS method has AUTH as none.
Good luck!
After enabling CORS on my endpoints I was receiving the same error message:
{"message":"Missing Authentication Token"}
Everything checked out, but I consistently received that error. To fix my issue I had to deploy the API. To do that, do the following:
Go to "Amazon API Gateway" console
Click on the API Gateway in question
Click "Resources" and select the root resource, e.g., "/"
Click "Actions" and then "Deploy API"
Select the stage you want to deploy to
Click "Deploy"
Long story short, redeploy the API after you've enabled CORS.
This mostly would be because of CORS issue.
Please enable CORS in you API gateway like below. After enabling CORS please redeploy the API
If you don't have OPTIONS added, please follow below steps (If OPTIONS already there just add CORS),
Create a new OPTIONS method under the /services resource
Create and populate the Access-Control-Allow-Origin/Method/Headers in the OPTIONS method.
Enable CORS like below after creating OPTIONS

How can I find out what my 'On-Premises Authority' url is?

I'm setting up a new .NET MVC project and want to use my local ADFS for managing users. I know the IP address of the machine my ADFS is running on and have tried using that for the 'On-Premises Authority' URL, but I got an message stating that it was incorrect.
Is there a command I can run to find the address/url that I should be using for this field?
For reference, this is the menu box I'm talking about:
You insert the metadata address of your ADFS e.g.
https://some-server/federationmetadata/2007-06/federationmetadata.xml
This must be provided by your IT-Team.
Usually it is:
https://YOUR-ADFS-SERVER/FederationMetadata/2007-06/FederationMetadata.xml

localhost.com redirects to google search

I am eager to know why localhost.com (without www) redirects to google.com. I also noticed that www.localhost.com gives a 404 page not found. I checked this in Firefox, Chrome and Internet Explorer all does the same. I checked the domain name records and it shows it belongs to Tucows and I am pretty sure Google doesn't own it and I know we can use http redirect to change it to a www or non-www version as the site owner wishes.
Interesting answer posted by Ken Watford, Google employee: http://www.quora.com/Why-does-http-localhost-com-redirect-to-Google
He claims someone bought the domain when the web was still young and kept it ever since, but he does not say who.
It looks like others have had the results as you, check out the links below.
Try here:
http://answers.yahoo.com/question/index?qid=20111105050333AATP1r5
or here:
http://forums.phpfreaks.com/topic/146474-localhost-redirects-to-googlecom/
I think localhost.com should be owned by google as I tried pinging it and it showed the ip of google.com.I still don't know why the DNS records shows tucows as the owner.
I have been searching this from long and finally i found complete solution after going through different answers.
As far as #pradeep's answer is concern, he is right that localhost.com is purchased and points to particular IP so it is redirecting.
But we can override domain names in Windows platform for our local development PC via hosts file residing in C:\Windows\System32\drivers\etc as per #Faysal's answer.
Open hosts file as administrator and enter following line
127.0.0.1 localhost.com
But doing such also did not solve my problem. So i found final solution which will work in chrome browser.
In chrome you have to clear all dns cache via opening following url
chrome://net-internals/#dns
And here clear all cache and finally you will be redirect localhost.com to your local server's home page.
If you are using the Windows platform, then go to your %windir%\System32\drivers\etc and copy the host file to %userprofile%\Desktop. Open it with any text editor and remove the # sign from the front of 127.0.0.1 localhost. Save it and paste it back. Check if the problem is solved.
localhost.com is a website. It does not point to your local IP, instead it most likely has an A record pointing to Google's IP. It practically is Google, and I can prove it.
When the site worked if you connected using HTTPS then it would give a certificate error, the reason being that the certificate is signed to google.com but localhost.com is connecting.
I think the site has now been removed though.... I hope that solves it. It can cause some confusion since localhost points to 127.0.0.1.

Google API OAuth for Drive API is not working. Getting Error: origin_mismatch

I am trying to run the quick start code of Real Time API of Google Drive.
I believe I did everything right. But I am getting
Error: origin_mismatch
Request Details
openid_connect_request=true
cookie_policy_enforce=false
scope=https://www.googleapis.com/auth/drive.install https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/plus.me
response_type=token
access_type=online
redirect_uri=postmessage
proxy=oauth2relay601571239
origin=http://127.0.0.1
state=811328575|0.818765953
display=page
client_id=XXXXXXXXXX
You haven't given much detail about your application architecture, so i can only suggest a general answer. OAuth restricts which URLs can be referred to it. The list of permitted URLs is configured in the API console at https://code.google.com/apis/console. The URL is very fussy, so make sure you enter it exactly as it appears in the address bar.
As at Oct 2013, you can't use localhost. You have 2 choices.
edit 127.0.0.1 = mydevserver.example.com into your /etc/hosts
use a url shortener (eg. goo.gl) to create an alias to localhost
However, I believe that it is now possible to configure localhost in the
Google api console.
I had same problem with origin_mismatch.
From: Create a client ID section localhost should work and worked for me after small testing.
Origin in Google API i have:http://localhost
URL to address bar in browser:localhost
From the beginning this configuration not works, but after i tried write to address bar: 127.0.0.1->enter->origin_mismatch, it's correct and after again write localhost, now it's works.
Tested same behaviour in Firefox 39 and Google Chrome 37.0.2062.120 Ubuntu 12.04 (281580) (64-bit).

Resources