Reddit.NET icon indicating copy to clipboard operation
Reddit.NET copied to clipboard

Browser Hangs when allowing

Open chrisjoly opened this issue 1 year ago • 5 comments

Hi Sirkris,

I have an issue, and I don't know where to go to solve it, so I'll post it here.

I implemented the code that you have here, following all the instructions, and all the parameters are correct, but when I accept, the browser just hangs there, and doesn't do anything. No responses of such.

When I did it initially, I did get an email confirming I authorized my app to have access to my reddit account, but I don't get any tokens returned to me.

What do you think would be the cause of this?

Sincerely,

Chris Joly

chrisjoly avatar Aug 08 '24 08:08 chrisjoly

Can you provide the specific code you used?

sirkris avatar Aug 08 '24 08:08 sirkris

public RedditClient logIntoReddit(Dictionary<string, string> credentials = null) { if (credentials == null) { // Hard Coded API credentials } else { string appId = credentials["appId"]; string appSecret = credentials["appSecret"]; string userAgent = credentials["userAgent"]; int port = int.Parse(credentials["port"]);

}

// authTokenRetriever is a variable declared at the class level this.authTokenRetriever = new Reddit.AuthTokenRetriever.AuthTokenRetrieverLib(appId, port,"localhost", null, appSecret);

// Start the callback listener.  --Kris
// Note - Ignore the logging exception message if you see it.  You can use Console.Clear() after this call to get rid of it if you're running a console app.
authTokenRetriever.AwaitCallback();


//// Replace this with whatever you want the app to do while it waits for the user to load the auth page and click Accept.  --Kris
RedditClient rdtClient;

// Get the authorization URL

string authorizationUrl = authTokenRetriever.AuthURL();

Console.WriteLine("Please visit the following URL to authorize your application:");
OpenBrowser(authorizationUrl);
Console.WriteLine("After authorization, paste the code you received here:");

// Read the authorization code from the console input
string authorizationCode = Console.ReadLine();

// Retrieve the refresh token
try
{

    string refreshToken = authTokenRetriever.RefreshToken;
    Console.WriteLine("Your refresh token is: " + refreshToken);
}
catch (Exception ex)
{
    Console.WriteLine("An error occurred: " + ex.Message);
}

rdtClient = new RedditClient(appId, authTokenRetriever.RefreshToken, appSecret, null, userAgent);
return rdtClient;

}

image

It's been hanging for the past few minutes

chrisjoly avatar Aug 08 '24 08:08 chrisjoly

MSVBot is the name of the application Many-Sirs-4588 is my Username

redditApp

chrisjoly avatar Aug 08 '24 08:08 chrisjoly

Hmm could there be a firewall or some other routing issue? Are you sure it's binding to port 8080 successfully? Maybe try a different port and see what happens?

sirkris avatar Aug 10 '24 09:08 sirkris

It's most likely the case! I have Norton, and their firewall is pretty robust! I have no idea how to allow ports through! I've tried a few other ports, but no dice!

Is there a programmatic way to open the port?

chrisjoly avatar Aug 13 '24 17:08 chrisjoly