I am using Windows Azure Mobile Services to log in using facebook. Once the user logs in I have the token but when I try to use this token with the facebook client I get a bad signature exeption.
Isnt it supposed to be the same token?
How are you getting the FB token? The token you receive from the mobile services client is the Azure Mobile Services token, and you can't use it with FB. To get the FB access token, you need to get it via a server script (with the user.getIdentities() function), as shown at http://blogs.msdn.com/b/carlosfigueira/archive/2012/10/25/getting-user-information-on-azure-mobile-services.aspx.
Another alternative is to use the Facebook SDK directly, which will give you a FB token (and you can then use that token to log in to Azure Mobile Services directly. The post at http://ntotten.com/2013/03/14/using-windows-azure-mobile-services-with-the-facebook-sdk-for-windows-phone/ has some information on how this can be done.
Related
I have a Web API developed with ASP.Net Core. I also have a client app developed with Next.js and it uses NextAuth.js to handle the authentication.
In the UI, when a user is authenticated, I have access to the access token from Facebook.
My question is how can I use this access token to authenticate the requests sent to the back-end API.
This is the back-end code used to register the Facebook authentication scheme (it is all standard):
builder.Services.AddAuthentication()
.AddFacebook(
facebookOptions =>
{
facebookOptions.AppId = "<my_app_id>";
facebookOptions.AppSecret = "<my_app_secret>";
});
I want to construct a Postman request that can authenticate my user using a specific access token but I do not know where to put this access token and whether this is possible at all.
Just sending the request like this (without any modifications) results in visualizing the Facebook login page.
Your Asp.NetCore project integrates Facebook login. After logging in, the token you get can only access protected resources in the current project, such as: [Authorize].
If you want to access Facebook's resources, you need to write your own code to get the token and then access the resources.
1. How to Get Facebook Access Token in a couple of minutes: 2020 guide
2. How to get current user access token from Facebook SDK in C#? Not the App access token
After you get facebook access_token, then you can access Facebook's resources.
I have a web application where I'm using Google API services which require an access-token.
All I want is a background process to get an access token and execute request without user's interfering.
I have tried various ways to get an access token (Google SDK Shell, Google Platform, Exchange auth code for access token).
When I'm working with Postman I have no problem with that but in my web application I don't want to redirect the user to the Google login for authorization to get the code and then request the access token. I don't want the authorization to be visible at all for my user.
I believe that auth token that we have in user.MobileServiceAuthenticationToken is the access token for the azure mobile service, my app needs to upload the image to user's FB album, so I need Facebook auth token on the client side, so that client can upload the pictures directly, it doesn't make sense to first send the pictures to backend and backend uploads the pictures.
As I known, you could retrieve the tokens from the client by sending an authenticated GET request to /.auth/me endpoint, then you would get a JSON response that contains a richer set of information about the logged in user as follows:
https://brucechen-mobile.azurewebsites.net/.auth/me
For refreshing tokens, you could call the built-in endpoint /.auth/refresh. For more details, you could follow this tutorial for a better understanding of Azure App Service Token Store.
I need to obtain a facebook page access token on the server.
From what I've read to obtain a page access token you must first obtain a user access token with the manage_pages permission then make a separate call to "me/accounts" to get the page access token.
The problem with this is the application I'm developing will automatically be publishing content to a Facebook page from the server. That being said obtaining the user access token from the backend is a problem.
Ideally I would like to programmaticly obtain the user access token then the page access token completely on the backend for the ability to automatically publish content to the page.
Any suggestions on how this can be done from the server side?
Thanks
It is not possible to get page access_token without authentication of user and manage_pages permissions granting.
Authenticating as a Page guide states:
First you need to authenticate a User, and obtain a User Access Token. To do this, please follow the server-side or client-side auth flows for the mobile web and desktop web, or the native iOS or native Android authentication flows.
Refer to Authentication documentation and Authenticating as a Page guide for details.
there is a problem with my access token. I have made my own application, and I took the permission from the facebook user, who is me. And also I have given the same permissions to the facebook graph api. However when I can easily get the results using FQL with graph api access token, but I cannot get the result with my own application access token. What is the problem with my access token.
It is not user access token. Maybe this can be problem however also graph api is not also user access token.
Per the error message you need to use a user access token retrieved via the Authentication flow - you cannot use an app access token for this.
You mentioned in the comments you're successfully using an access token from the Graph API Explorer tool - this is also a user access token which the tool retrieves using the client-side oauth flow. This is not the same as using an app access token for your own app.