-
Notifications
You must be signed in to change notification settings - Fork 23
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
Authenticating with an installed app, app type #43
Comments
Hi @Ivaskuu, Thanks for the issue! It looks like there's some potential issues with providing the arguments to import 'package:draw/draw.dart';
main() async {
// Create a `Reddit` instance using a configuration file.
final reddit = await Reddit.createInstance(userAgent: 'foobar', configUri: Uri.parse('draw.ini'));
// Build the URL used for authentication. See documentation for `WebAuthenticator` for parameters.
final auth_url = reddit.auth.url(['*'], 'foobar'));
// ...
// Complete authentication at `auth_url` in the browser and retrieve the `code` query
// parameter from the redirect URL.
// ...
// Assuming the `code` query parameter is stored in a variable `auth_code`, we pass it to the
// `authorize` method in the `WebAuthenticator`.
await reddit.auth.authorize(auth_code);
// If everything worked correctly, we should be able to retrieve information about the authenticated
// account.
print(await reddit.user.me());
} And here's an example default=default
reddit_url='https://www.reddit.com'
oauth_url=https://oauth.reddit.com
redirect_uri=https://www.google.com
client_id=YOUR_CLIENT_ID_HERE
client_secret=YOUR_SECRET_HERE
userAgent=draw_testing_agent I've registered my Reddit application's redirect URI to be https://www.google.com, but you'll need to replace that with whatever redirect you have registered. The format of If you have any more issues, please feel free to ask us through GitHub issues or our Gitter chat and I'll get back to you ASAP. |
Excuse me, @bkonyi, but in your example, |
I'm guessing you're using an IDE like Intellij or Visual Studio Code? If so, you might see the errors under those lines (I should update the base Authenticator to have Doing the following should work: // Putting a type on the left-hand side will cast the `Authenticator` into a `WebAuthenticator`.
// You could also do `(reddit.auth as WebAuthenticator).url()`, but that gets messy if you need to do it
// more than once.
final WebAuthenticator auth = reddit.auth;
// Build the URL used for authentication. See documentation for `WebAuthenticator` for parameters.
final auth_url = auth.url(['*'], 'foobar'));
// ...
// Complete authentication at `auth_url` in the browser and retrieve the `code` query
// parameter from the redirect URL.
// ...
// Assuming the `code` query parameter is stored in a variable `auth_code`, we pass it to the
// `authorize` method in the `WebAuthenticator`.
await auth.authorize(auth_code); |
Sorry for commenting on this long closed issue, but I wanted to let you know that I struggled with the same question and could not find any documentation on the error. When chosing the type "installed app", you dont have a secret, yet there is no constructor in DRAW that doesnt contain a secret except for the UntrustedReadOnlyIntstance. I ended up solving this issue like this: `
` but I would much rather prefer having a dedicated constructor that does the same. What do you think? (By the way, using draw: ^0.4.6+1) |
Ah, this must have been an oversight on my part when I made individual static methods for each authentication type to replace the catch-all |
@bkonyi Really sorry for annoying you, but there doesn't appear to be this - does the empty client secret thing still work? |
Hi :) putting an empty client secret ("") still works for me. |
Obviously there's still some confusion here, so I'll reopen this issue. @StefanLobbenmeier, @naiveai what's the use case you have? What's the expected behavior? |
The use case is to use DRAW in a Flutter app, using the installed app type in Reddit's app registration. There is no secret provided to us when doing this, so we have to simply pass it in as empty when creating a Reddit instance. I ended up doing that and it worked, so all it needs at this point is a dedicated constructor that passes in |
Hm, I totally thought I had covered this case... anyway, I'll add a proper way to initialize for an installed application type. |
|
Minor problem, |
I think that having the client secret somewhere In the code is safer than
having it in the code and in the saved Authentication
|
@StefanLobbenmeier the client secret doesn't exist with installed apps, so I'm not sure what you mean here. |
Whoops, totally forgot about that! Thanks for pointing it out, I'll update things :) |
Hi!
How could I init DRAW if I have an installed app type for reddit? Does DRAW support this type of app?
I've tried the base Reddit.createInstance and specifying only the clientId, redirectUri and userAgent, but it doesn't seem to work.
For instance, this is what I am trying to get:
![Example](https://camo.githubusercontent.com/55743423b82021caeca815ac34d341612261ce4cd29b36549b424e671c693f45/68747470733a2f2f692e6779617a6f2e636f6d2f30333235353334663338623738633164626434633834643639306464613663322e706e67)
Thank you for the plugin, and for the help.
The text was updated successfully, but these errors were encountered: