Coder Social home page Coder Social logo

Comments (8)

StefanLobbenmeier avatar StefanLobbenmeier commented on July 19, 2024

Hi :) I think there are some parameters missing. Let me check my code

from draw.

StefanLobbenmeier avatar StefanLobbenmeier commented on July 19, 2024
Future<Reddit> login(String state) async {
    Reddit _reddit;
    final userAgent = randomAlphaNumeric(30);

    // Create a `Reddit` instance using a configuration file in the
    // current directory.
    _reddit = Reddit.createWebFlowInstance(
      clientId: clientId,
      clientSecret: "", // Yes, leave it empty
      userAgent: userAgent,
      redirectUri: Uri.parse(redirectUrl),
    );
    //
    //  // Build the URL used for authentication. See `WebAuthenticator`
    //  // documentation for parameters.
    final authUrl = _reddit.auth.url(
      ['*'],
      state,
      compactLogin: true,
    );
    print(authUrl);
    print("state: $state");
    await openLoginPageInBrowser(authUrl.toString());
    return _reddit;
  }

from draw.

StefanLobbenmeier avatar StefanLobbenmeier commented on July 19, 2024

This is the Code I Uwe (and just tested). However youre using the newer api and I guess you should keep that. What I missed in your code was the state

from draw.

StefanLobbenmeier avatar StefanLobbenmeier commented on July 19, 2024

Actually never mind, that part looks correct. My next guess is that your way of extracting the code did not work, did you check the code with a print?

from draw.

StefanLobbenmeier avatar StefanLobbenmeier commented on July 19, 2024

The other reason I could think of is that the reddit api does not accept foobar as it is not random enough / used by too many people

from draw.

ThatsEli avatar ThatsEli commented on July 19, 2024

I managed to fix it by using a different useragent as you suggested. Somehow that fixed it, I don't know exactly why that mistake would throw the error I had, but who knows 🤔 Dankeschön für die Hilfe ;) (Thank you for the help!)

from draw.

StefanLobbenmeier avatar StefanLobbenmeier commented on July 19, 2024

@bkonyi should we change this in the Guide? It seems that it was not clear that user_agent needs to be random

from draw.

bkonyi avatar bkonyi commented on July 19, 2024

@bkonyi should we change this in the Guide? It seems that it was not clear that user_agent needs to be random

Thanks for helping @ThatsEli debug @StefanLobbenmeier! I really appreciate your contributions :)

Yes, we should probably add a commonly asked questions section to the README and cover this there. I'm not certain the user-agent needs to be random, but it needs to be something relatively unique (I'm sure foobar is used quite frequently, which is likely why @ThatsEli was running into issues. Us programmers are too damn predictable, I guess :-) ).

from draw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.