How to extend Ally?


#1

Hi,

I want add more provider on Ally, as Tumblr and Medium, how I can extend Ally? And which file I have to add to extend this package?

Thanks.


#2

Hi,

I would imagine you’d create a driver. See here

Don’t forget to add tests.

Hope this helps :smiley:


#3

I tried to extend with Tumblr provider.

{ OAuthException: E_OAUTH_TOKEN_EXCHANGE: oauth_signature does not match expected value
at Function.tokenExchangeException (C:\Users\Maxence\Documents\Projets\test-project\node_modules@adonisjs\ally\src\Exceptions\index.js:36:19)
at Tumblr.parseProviderError (C:\Users\Maxence\Documents\Projets\test-project\node_modules@adonisjs\ally\src\Schemes\OAuth.js:135:30)
at client.getOAuthAccessToken (C:\Users\Maxence\Documents\Projets\test-project\node_modules@adonisjs\ally\src\Schemes\OAuth.js:189:32)
at C:\Users\Maxence\Documents\Projets\test-project\node_modules\oauth\lib\oauth.js:465:22
at passBackControl (C:\Users\Maxence\Documents\Projets\test-project\node_modules\oauth\lib\oauth.js:397:13)
at IncomingMessage. (C:\Users\Maxence\Documents\Projets\test-project\node_modules\oauth\lib\oauth.js:409:9)
at IncomingMessage.emit (events.js:165:20)
at endReadableNT (_stream_readable.js:1101:12)
at process._tickCallback (internal/process/next_tick.js:152:19)
original:
{ statusCode: 401,
data: ‘oauth_signature does not match expected value’ } }

The Github repository is: https://github.com/pirmax/adonis-ally

Thanks to help me.


#4

Yeah this is an odd one. I can’t seem to get beyond this either. I’m on it though will report back with my findings.


#5

Now, it’s Medium who give me an error…

I try to connect my website account on Medium (blog), via this URL:

https://medium.com/m/oauth/authorize?redirect_uri=https%3A%2F%2Fdomain.com%2Fnetworks%2Fmedium%2Fcallback&scope=basicProfile&response_type=code&client_id=7510274391b7

But, I get this Medium error:

We didn’t understand your request.

enter image description here


#6

You can check this repo for inspiration.


#7

Yes, I know.

But…

I extended Bitly provider:

But the problem is they is a concat of baseUrl() and accessTokenUrl()…

Could you help me please?

Thanks.


#8

Hi,

this._getAccessTokenUrl() parse this._baseSite + this._accessTokenUrl

But the endpoint URL of Bit.ly is https://bitly.com/, the authorize URL is oauth/authorize and the access token URL is https://api-ssl.bitly.com/oauth/access_token

  /**
   * Base url to be used for constructing
   * google oauth urls.
   *
   * @attribute baseUrl
   *
   * @return {String}
   */
  get baseUrl () {
    return 'https://bitly.com/'
  }

  /**
   * Relative url to be used for redirecting
   * user.
   *
   * @attribute authorizeUrl
   *
   * @return {String} [description]
   */
  get authorizeUrl () {
    return 'oauth/authorize'
  }

  /**
   * Relative url to be used for exchanging
   * access token.
   *
   * @attribute accessTokenUrl
   *
   * @return {String}
   */
  get accessTokenUrl () {
    return 'https://api-ssl.bitly.com/oauth/access_token'
  }

Authorize URL will be: https://bitly.com/oauth/authorize
And Access Token URL will be (incorrect): https://bitly.com/https://api-ssl.bitly.com/oauth/access_token

It’s impossible to add Bitly in provider of Ally, could you help me please?