Skip to content

Commit 7b64f28

Browse files
committed
feat: end-to-end token generation
1 parent a6d08e1 commit 7b64f28

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

__test__/client.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('getToken(reqUrl)', () => {
4545

4646
beforeAll(() => {
4747
client = new Client(config);
48-
axios.post.mockImplementation(async () => token_json);
48+
axios.post.mockImplementation(async () => {return {data: token_json}});
4949
});
5050

5151
it('should throw an exception if the request does not contain all scopes requested', async () => {

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const { Client } = require('./lib/client');
2+
const { Token } = require('./lib/token');
3+
4+
module.exports = { Client, Token }

lib/client.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ class Client {
7171
});
7272

7373
const token = new Token(
74-
res.token_type,
75-
res.expires_at,
76-
res.expires_in,
77-
res.refresh_token,
78-
res.access_token,
79-
res.athlete
74+
res.data.token_type,
75+
res.data.expires_at,
76+
res.data.expires_in,
77+
res.data.refresh_token,
78+
res.data.access_token,
79+
res.data.athlete
8080
)
8181

8282
return token;

lib/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
authorization_uri: 'https://www.strava.com/api/v3/oauth/authorize',
3-
token_uri: 'https://www.strava.com/oauth/api/v3/token',
4-
revocation_uri: 'https://www.strava.com/oauth/api/v3/deauthorize',
3+
token_uri: 'https://www.strava.com/api/v3/oauth/token',
4+
revocation_uri: 'https://www.strava.com/api/v3/oauth/deauthorize',
55
client_id: null,
66
client_secret: null,
77
redirect_uri: 'https://localhost',

lib/token.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Token {
1111
this.expires_in = expires_in;
1212
this.refresh_token = refresh_token;
1313
this.access_token = access_token;
14-
this.athelete = athlete;
14+
this.athlete = athlete;
1515
}
1616
}
1717

0 commit comments

Comments
 (0)