Skip to content
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

Looking for guidance on how to use TraktManager.Authentication.authorizeApplication() #1

Open
efraimbart opened this issue Feb 28, 2022 · 5 comments

Comments

@efraimbart
Copy link

I cannot seem to figure out the way to use TraktManager.Authentication.authorizeApplication(). It seems to just be making the request via an http client, with no means for user input or to thereafter retrieve the code.

Any help on this would be greatly appreciated!

@shamith16
Copy link

Hey any luck on this?

@efraimbart
Copy link
Author

If I recall correctly I forked the code and hacked in a WebView

@efraimbart
Copy link
Author

@shamith16 I dug through my code and it looks like I updated trakt_dart's authorizeApplication() method as follows

  /// Construct then redirect to this URL.
  ///
  /// The Trakt website will request permissions for your app, which the user needs to approve.
  /// If the user isn't signed into Trakt, it will ask them to do so.
  /// Send signup=true if you prefer the account sign up page to be the default.
  Future<void> authorizeApplication({bool? signup}) async {
    final url = Uri.parse(_manager._oauthURL);
    await ChromeSafariBrowser().open(url: url);

    // final response = await _manager.client
    //     .get(url, headers: {"Content-Type": "application/json"});
    //
    // if (![200, 201, 204].contains(response.statusCode)) {
    //   throw TraktManagerAPIError(
    //       response.statusCode, response.reasonPhrase, response);
    // }
  }

and set the return url to a deeplink, and handled then handled the code as below

await traktManager.authentication.getAccessToken(traktCode!);

@shamith16
Copy link

Thanks. will give it a try

@paraflu
Copy link

paraflu commented Sep 30, 2022

With the device authentication flow https://trakt.docs.apiary.io/#reference/authentication-devices you can avoid this trick (an example can be found here #2) but there are some bug in current implementation I've done a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants