Question: I've made a program that simply creates an HTML file in the location where the Python script is executed.

The problem is that after having freeze my application with PyInstaller, the executable no longer creates the HTML file as intended but does nothing. (It only makes the print statement of my program appear.)

Is there a way to get around this?

\*I used the `open("x.html","w+")` function to create the HTML file.

The code that creates the HTML looks like this:

```
def create_html():
    f = open("x.html", "w+")
    f.write("<!DOCTYPE html>\n<html>\n<body>\n")
    f.close()

```

I think what would fix the problem is to create the html file outside the working directory. However I have no idea how to do that.

After looking around I've found that my program does indeed work but creates the html file in the home directory on my mac. Is there a way to change that?

Answer: 
To sign in with Twitter do the following:

```
 Future<FirebaseUser> loginWithTwitter() async {
  var twitterLogin = new TwitterLogin(
    consumerKey: 'key',
    consumerSecret: 'secretkey',
  );

  final TwitterLoginResult result = await twitterLogin.authorize();

switch (result.status) {
  case TwitterLoginStatus.loggedIn:
    var session=result.session;
    final AuthCredential credential= TwitterAuthProvider.getCredential(
      authToken: session.token,
      authTokenSecret: session.secret
    );
    FirebaseUser firebaseUser=(await firebaseAuth.signInWithCredential(credential)).user;
    print("twitter sign in"+firebaseUser.toString());
    break;
  case TwitterLoginStatus.cancelledByUser:
    break;
  case TwitterLoginStatus.error:
    break;
}

```

Use `twitterlogin` and pass the consumer key and consumer secret key, then use the method `getCredential()` and `signInWithCredential` to log in.
This worked for me. (Referred from <https://firebase.flutter.dev/docs/auth/social#twitter>)

```
import 'package:twitter_login/twitter_login.dart';

Future<UserCredential> signInWithTwitter() async {
  // Create a TwitterLogin instance
  final twitterLogin = new TwitterLogin(
    apiKey: '<your consumer key>',
    apiSecretKey:' <your consumer secret>',
    redirectURI: '<your_scheme>://'
  );

  // Trigger the sign-in flow
  final authResult = await twitterLogin.login();

  // Create a credential from the access token
  final twitterAuthCredential = TwitterAuthProvider.credential(
    accessToken: authResult.authToken!,
    secret: authResult.authTokenSecret!,
  );

  // Once signed in, return the UserCredential
  return await FirebaseAuth.instance.signInWithCredential(twitterAuthCredential);
}

```

This wasn't working initially for me.

Things I had to change in order for this to work.

1. Request for Elevated Permissions in Twitter Developer Portal.
2. Create a custom scheme (callback URL) and configure the ios/android files accordingly. As given in (<https://pub.dev/packages/twitter_login>).
3. Also configure this callback URL in the Twitter dev portal.