I am currently developing a smartphone application using cordova.
Send the access token obtained by logging in to FB on the app side to the server side and
On the server side, I would like to log in again after FB authentication to see if the token is correct.
The following error occurred while checking the token sent by the server side:
I can't resolve it.
"You must provide an app access token or a user access token that is an owner or developer of the app"
*There is no error on the terminal registered as FB administrator.An error occurs when accessing by a regular user.
We have obtained the necessary parameters such as access tokens and user IDs.
Development Language
Client Side
·react.js
Server Side
·ruby on rails
US>Your device
·iPhone (IOS9)
API in use
in use
Client side...get access token
·cordova-plugin-facebook4
Server Side...Check Access Token
·koala (Graph API)
US>Your Server
·AWS
Permissions used by FB
·email
·public_profile
·user_friends
·user_birthday
·user_work_history
---
Sources of Errors
US>def verify_facebook_token!
@graph=Koala::Facebook::API.new(params[:facebook_token])
# Contact https://graph.facebook.com/debug_token ?
[email protected]_token(params[:facebook_token])←Error here
#Check to see if it has expired.
raise ArgumentErrorless token_info ['data'] ['is_valid']
# Also check user_id on Facebook
raise ArgumentErrorless token_info ['data']['user_id'].eql?(params[:facebook_id])
# The app_id is a fixed value because I know it when I first registered the app.
raise ArgumentErrorless token_info['data']['app_id'].eql?(ENV['FACEBOOK_APP_ID'])resque
logger.info("is_valid:#{@graph.debug_token(params[:facebook_token])}")
render template: 'api/v1/errors/facebook_token', status: 400 end
---
Error Log
Koala::Facebook::ClientError(type:OAuthException,code:100,message:(#100)You must provide an app access token or a user access token that is an owner or developer of the app,x-fb-trace-id:GjfLrs52rVy[HTTP400]
app/controllers/api/auth_controller.rb:34:in resque in verify_facebook_token!'
verify_facebook_token!'
app/controllers/api/auth_controller.rb:28:in
@graph=Koala::Facebook::API.new(params[:facebook_token])
Is there a user token in the params[:facebook_token] I gave you at this time?
First of all, /debug_token is not accessible with user tokens.
https://developers.facebook.com/docs/graph-api/reference/v2.6/debug_token/
Permissions: An app access token or an app developer's user access token for the app associated with the input_token is required to access this endpoint.
Instead, you need to use the app token or the developer's user token. (This may be the reason why the terminal registered as FB administrator does not fail)
In many cases, you will probably use the app token to hit /debug_token.App token can be generated via Graph API, but it seems that app ID and app secret can be used as app token.In that case, use a string similar to the following that connects the two with a pipe as a token.
app_id|app_secret
Note: https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens
I hope this solves the problem... Please try it.
© 2024 OneMinuteCode. All rights reserved.