User data is null in Instagram api
Hi, everyone I'm using instagram auth I get mt client id, my client secret id and redirect link but I have an issue user info get always empty I made myself tester but still same issue and accept authorization from my phone but same issue
import 'package:flutter/material.dart';
import 'package:instagramintegration/AppConstants.dart';
import 'package:simple_auth/simple_auth.dart' as simpleAuth;
import 'package:simple_auth_flutter/simple_auth_flutter.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
SimpleAuthFlutter.init(context);
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String userInfo = '';
final simpleAuth.InstagramApi instagramApi = new simpleAuth.InstagramApi(
"instagram", AppConstants.clientId, AppConstants.clientSecretId, AppConstants.redirectUrl,
scopes: ["user_profile","user_media"]
);
void _instagramLogin() async {
login(instagramApi);
}
void showMessage(String text) {
var alert = new AlertDialog(content: new Text(text), actions: <Widget>[
new FlatButton(
child: const Text("Ok"),
onPressed: () {
Navigator.pop(context);
})
]);
showDialog(context: context, builder: (BuildContext context) => alert);
}
void login(simpleAuth.AuthenticatedApi api) async {
try {
var success = await api.authenticate();
print("DATA");
print(success.toJson().toString());
setState(() {
userInfo = success.userData.toString();
});
} catch (e) {
setState(() {
userInfo = '';
});
showError(e);
}
}
void showError(dynamic ex) {
showMessage(ex.toString());
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
userInfo,
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: new FloatingActionButton(
onPressed: _instagramLogin,
tooltip: 'Login',
child: new Icon(Icons.flash_on),
),
);
}
}
Hey there, Instagram doesn't return any user data after authentication. We need to make a separate request. I wrote a complete guide on using Instagram's Basic Display API, which you can find here: https://blog.maskys.com/using-the-instagram-basic-display-api-in-flutter/
@Clancey, would you consider doing this internally in InstagramApi?
Correct, Making a call to get the user profile is a separate call. The google version has the user profile stubbed out. I am not against having some api calls built in.
Hey there, Instagram doesn't return any user data after authentication. We need to make a separate request. I wrote a complete guide on using Instagram's Basic Display API, which you can find here: https://blog.maskys.com/using-the-instagram-basic-display-api-in-flutter/
Hello, is it possible to update the _loginAndGetData() function to the new Flutter version? Because I have the return The argument type 'Future<Null> Function(Account)' can't be assigned to the parameter type 'FutureOr