Skip to content

Migrate exchangeCodeForToken to node-fetch#214

Merged
sdwvit merged 3 commits intonylas:mainfrom
TrySound:fetch-exchange-code-for-token
Mar 16, 2021
Merged

Migrate exchangeCodeForToken to node-fetch#214
sdwvit merged 3 commits intonylas:mainfrom
TrySound:fetch-exchange-code-for-token

Conversation

@TrySound
Copy link
Copy Markdown
Contributor

Ref #174

Migrating whole library from "request" at once would be quite massive.
In this diff I migrated only exchangeCodeForToken to figure out how to
test and install dependencies.

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

Ref nylas#174

Migrating whole library from "request" at once would be quite massive.
In this diff I migrated only exchangeCodeForToken to figure out how to
test and install dependencies.
@TrySound
Copy link
Copy Markdown
Contributor Author

cc @sdwvit

Comment thread src/nylas.ts
url.searchParams.set('client_id', this.clientId);
url.searchParams.set('client_secret', this.clientSecret);
url.searchParams.set('grant_type', 'authorization_code');
url.searchParams.set('code', code);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using URL is an interesting choice here ;) is it just to urlencode querystring? looks good to me, just wanted to point out

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Browser support makes it more preferred choice over querystring

Comment thread src/nylas.ts Outdated
return callback(null, body['access_token']);
callback(error);
}
throw error;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it make sense to recreate an Error so it includes current frame in a stacktrace?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@sdwvit sdwvit requested a review from Gerdie January 21, 2021 21:23
TrySound added a commit to TrySound/nylas-nodejs that referenced this pull request Feb 7, 2021
Ref nylas#174 nylas#214

Another migration example with node streams.
@TrySound
Copy link
Copy Markdown
Contributor Author

Hi @sdwvit @Gerdie, is it good to go?

@sdwvit sdwvit merged commit a11d67e into nylas:main Mar 16, 2021
sdwvit pushed a commit that referenced this pull request Mar 16, 2021
Ref #174 #214

Another migration example with node streams.
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

Successfully merging this pull request may close these issues.

2 participants