I already have here maps implemented with leaflet using app_code and app_id now I want to use it through accesstoken but it is showing Bad request when I send url request.
Can we use AccessToken to access Here map from Leaflet?
Related
I want to do oAuth2 verification in my website login page and after that I want to get token from url with same page but issue is i can`t able to get URL.
below URL is OAuth2 url using this url I am doing authentication steps with website using flutter.
1st this website will open in browser after that login page will open and after login i will get access_token. But i facing difficulties how i can get access_code with html.window.location function.
I have tried with this code
WidgetsBinding.instance!.addPostFrameCallback((_) {
html.window.location.assign(
'https://example/connect/authorize?response_type=token&client_id=$clientId&redirect_uri=https://example.app/silentRenew&scope=getinfo');
});
Anyone have better solution than please give suggestion.
Pinal! I did an oAuth2 flux recently consuming Gitlab API. I suggest you to use
the oauth2 plugin: oauth2. You just need to have the authorization endpoint, access token endpoint and the redirect url.
After this, you just need to call 3 methods.
Getting your AuthorizationCodeGrant.
var grant = oauth2.AuthorizationCodeGrant(identifier, authorizationEndpoint, tokenEndpoint,secret: secret)
Get Authorization Url.
var authorizationUrl = grant.getAuthorizationUrl(redirectUrl);
Get the returned Code.
await grant.handleAuthorizationResponse(responseUrl.queryParameters);
The method return your code automatically.
In my case, I used a webview instead opening the browser to listen the redirected url's. WebView
You just have to pass the authorizationUrl as the initial page flag inside webview, and listen to the url's with onPageStarted flag. So what you wanna do is: when the redirectUrl ,which gives you the code to authorize your access token, is accessed you call the method 3, only in this moment. I hope this help you, let me know if you struggle with something.
I'm trying to force facebook to update the OG information automatically using javascript (i.e. what you can manually do on this page), using an app access token.
I've been able to make it work using a user access token and the api with the following code:
FB.api("/", "post", {
accessToken,
id: url,
scrape: true
}, function(response) {
console.log("Response", response)
}
);
However when I try to use the app access token I get the error
"message":"An access token is required to request this resource.",
"type":"OAuthException",
"code":104"
I've tried obtaining the access token both using a GET request:
GET /oauth/access_token
?client_id={app-id}
&client_secret={app-secret}
&grant_type=client_credentials
and by concatenating the add id and secret.
The result is the same when using curl instead of the Javascript api.
It seems to me it can't be intended that you can force an OG scrape as a user but not with an app token; it doesn't sound like a user oriented action.
Any ideas?
i'm facebook js sdk for users login,
at the server side i want to get the user data
i'm trying to use
Socialite::with('facebook')->user()
to make it work it need 2 query string code and status
in my JavaScript i'm using the following
var auth_status_change = function(response) {
console.log(response);
if(response.status == "connected")
{
window.location = "{{URL::to(App::getLocale()."/fb_login")}}?code="+??+"&state="+???;
}
}
FB.Event.subscribe('auth.statusChange', auth_status_change);
how to get the state and code values to create a valid callback URL for socialite
You're trying to combine 2 things that do the same thing, but one on the server side and one on the client side, that won't work.
Laravel Socialite uses your app token to redirect your user to Facebook, authorize your app to use Facebook on their behalf (token) and provides you with user data. With the token you can do API calls from Laravel.
The Facebook JS SDK does the same thing, but in the browser. It fetches a token which it uses to do API calls.
Check out https://laracasts.com/series/whats-new-in-laravel-5/episodes/9 on how Socialite works.
Unless you are using the JS SDK functionality, you can leave it out and just add a link to a socialite route which redirects it to Facebook. That call will provide you with the code and state required to fetch the user.
As stated in the Facebook Oauth Documentation, in order to use the Client Side Flow with a Desktop App, the special return_uri https://www.facebook.com/connect/login_success.html is required.
Opening a new tab from Chrome to the url
https://www.facebook.com/dialog/oauth?client_id=MYAPPID&redirect_uri=https://www.facebook.com/connect/login_success.html&response_type=token
works as expected, I am redirected to the login_success page with an access_token parameter containing the token. I can request data from the Graph API using simple GET requests (e.g., with jQuery):
$.getJSON("https://graph.facebook.com/me", {access_token : token}, function (d)
{
.. process returned data
});
My question is, can I continue to use the Javascript SDK without using the SDK's internal authorization methods.
FB.getLoginStatus returns an error that my Connect/Canvas URI isn't correct. How am I supposed to check the token status without that method [apart from a manual GET and response matching]?
FB.login obviously fails with the following error:
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: Invalid redirect_uri
(url does not match domain url in the app's config), as there seems to be no way to internally specify the return_uri above.
Is there a way to still rely on the Javascript SDK (especially events) while accessing a token externally? Am I supposed to override the access token?
Yes, you can use it for the normal events (i.e. someone clicked a like button) like so:
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js#xfbml=1" id="facebook-jssdk"></script>
<script type="text/javascript">
FB.Event.subscribe('edge.create',
function(response) {
console.log(response);
}
);
</script>
Unfortunately for regular API calls you can't use the Facebook JS SDK from within your extensions. You'll have to roll your own API wrapper for that.
An easy way to see if the access token is valid, is to make a graph API call to /me?fields=id with the access token you have saved. That will be fast and you can use the response to see if the access token is still valid. Best practice for extensions is to request the permission offline_access.
Also, I would recommend having the redirect URI be on a domain you own. That way if other extensions are doing the same, your scripts won't interfere. Accessing the token will be the same.
I'm logged in using to my own Application using C# Facebook SDK and I can read/write/delete all data I need.
However for validation purposes I'd like to get AppID that I'm currently using (the one I used when generating login Uri) based on existing valid Access-token and Facebook.FacebookClient object.
In a similar way like in Facebook PHP SDK: $appId = Facebook->getAppId();
My access token is not like string.Concat(appId, "|", appSecret)
If I use Facebook C# Sdk I may use following code to retrieve appID I used when loging in - if at the moment I have in memmory only AccessToken available:
string myAccessToken = "...";
FacebookClient fc = new FacebookClient(myAccessToken);
IDictionary<string, object> resultContainer =
(IDictionary<string, object>)fc.Get("/app");
string retrievedAppID = resultContainer["id"] as string;
The same result can be obtained directly from Graph Api Explorer via:
https://graph.facebook.com/app
If desired Facebook application is selected at top right part of the Graph Api Explorer page.
In the Facebook C# SDK, there is no where that access_token parses(or decoded).
Naturally, Facebook C# SDK api, it takes appId from Web.Config through the FacebookSettings class.
access_token as string property of FacebookSignedRequest class.
So you may follow this link to do it yourself: https://developers.facebook.com/docs/authentication/signed_request/
You should be able to get the AppId like this:
var appId = Facebook.FacebookApplication.Current.AppId;