Skip to content
This repository has been archived by the owner on Aug 13, 2020. It is now read-only.

Document QueryString functionality #27

Open
wispborne opened this issue Mar 13, 2017 · 1 comment
Open

Document QueryString functionality #27

wispborne opened this issue Mar 13, 2017 · 1 comment

Comments

@wispborne
Copy link

wispborne commented Mar 13, 2017

I just went down a rabbit hole of debugging that eventually led me to find that RxSocialConnect always assumes that the "oauth_verifier" parameter will be present.

If it's not present, it'll fail, even if the "oauth_token" parameter is present. This is the case on Goodreads - an example callback url from the api is "oauth://tir?oauth_token=xxxxxxxxxxxxx&authorize=1"

The solution for me was to replace the StrategyOAuth1 with a custom parser, which seems to be working fine, but it's quite non-intuitive. Maybe some documentation of this hidden feature is in order, assuming I have the facts straight.

For anyone else having the same problem, here's what my code looks like:

        QueryString.PARSER.replaceStrategyOAuth1(object : QueryStringStrategy {
            override fun extractCode(uri: Uri): String {
                return uri.getQueryParameter("oauth_token")
            }

            override fun extractError(uri: Uri): String? {
                return uri.getQueryParameter("error")
            }

        val goodReadsService = ServiceBuilder()
                .apiKey("xxxxxxxxxxxxxxxxxxxx")
                .apiSecret("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
                .callback(GoodreadsApi.CALLBACK_URI)
                .build(GoodreadsApi())

        RxSocialConnect.with(activity, goodReadsService)
                .subscribe({ response ->
                    TimberKt.d { response.token().token }
                }, { error ->
                    TimberKt.e(error, { "Couldn't get token!" })
                })

Oh, and thank you for this lib, it is awesome.

@VictorAlbertos
Copy link
Owner

thanks @DavidWhitman I'm planing to upgrade the internal dependency of Scribe soon, so I'll give some time to this issue.

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

No branches or pull requests

2 participants