Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An access token is required to request this resource. #105

Closed
chandan7193 opened this issue Jun 27, 2017 · 1 comment · Fixed by bluet/facebook-node-sdk#4
Closed

An access token is required to request this resource. #105

chandan7193 opened this issue Jun 27, 2017 · 1 comment · Fixed by bluet/facebook-node-sdk#4

Comments

@chandan7193
Copy link

I not able to login using this npm
This is my code
`
import React, { Component } from 'react';
import { Grid } from 'semantic-ui-react';
import {FB, FacebookApiException} from 'fb';
import './SignUp.css';

class SignUp extends Component{

constructor(props) {
	super(props);
	this.handleLogin = this.handleLogin.bind(this);
}


componentDidMount() {
	FB.options({version: 'v2.5',appId: 'xxx', appSecret: 'xxxx'});
	
}

handleLogin(e: any){
	FB.api('4', { fields: ['id', 'name'] }, function (res) {
	  if(!res || res.error) {
	    console.log(!res ? 'error occurred' : res.error);
	    return;
	  }
	  console.log(res.id);
	  console.log(res.name);
	});
};


render(){
	return(
		<div className="message">
		<Grid divided="vertically" columns="equal">
		<Grid.Row>
		<Grid.Column>
		<div className="UserDetails">
			<button className="button" onClick={this.handleLogin}>Login</button>
		</div>
		</Grid.Column>
		</Grid.Row>


		</Grid>
		</div>

		);
}

}
export default SignUp;
`

Console is showing me message

GET https://graph.facebook.com/v2.5/4?fields=%5B%22id%22%2C%22name%22%5D 400 ()

Object {message: "An access token is required to request this resource.", type: "OAuthException", code: 104, fbtrace_id: "BvsKVSG1Xo1"}

@dantman
Copy link

dantman commented Jun 27, 2017

You're not logging in at all. All you're doing is making an api call to /4.

Additionally this is a node js (server side) library not a client. You have to handle login separately using a manual login flow or Facebook's client sdk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants