Martin Berg Alstad 4a773e4b43
🔑 Store tokens in Sqllite, moved queries, other fixes
- Create cache dir if missing
- Moved Sqlite queries to queries.ts
- Updated dependencies
- Added pino-pretty to dev-dependencies
- Changed Sqlite to store tokens as separate rows
- Removed in-memory storage of tokens
- isValidToken function
- Throw Exception if refresh token is present but invalid
- Fixed fetch query in smn http file
2025-01-22 21:00:04 +01:00

57 lines
1.8 KiB
HTTP

@oauthBaseUrl = https://api.sparebank1.no/oauth
@bankingBaseUrl = https://api.sparebank1.no/personal/banking
### Authorize with Sparebank1
GET {{oauthBaseUrl}}/authorize?client_id={{sparebank1OauthClientId}}&
state={{sparebank1OauthState}}&
redirect_uri={{sparebank1OauthRedirectUri}}&
finInst=fid-smn&
response_type=code
### OAuth2 Access Token Request
# Refresh token is valid for 365 days
# Access token is valid for 10 minutes
POST {{oauthBaseUrl}}/token
Content-Type: application/x-www-form-urlencoded
client_id = {{sparebank1OauthClientId}} &
client_secret = {{sparebank1OauthClientSecret}} &
code = {{sparebank1OauthAuthCode}} &
grant_type = authorization_code &
state = {{sparebank1OauthState}} &
redirect_uri = {{sparebank1OauthRedirectUri}}
> {%
client.global.set("ACCESS_TOKEN", response.body.access_token)
client.global.set("REFRESH_TOKEN", response.body.refresh_token)
%}
### OAuth2 Access Token Refresh
POST {{oauthBaseUrl}}/token
Content-Type: application/x-www-form-urlencoded
client_id = {{sparebank1OauthClientId}} &
client_secret = {{sparebank1OauthClientSecret}} &
refresh_token = {{REFRESH_TOKEN}} &
grant_type = refresh_token
> {%
client.global.set("ACCESS_TOKEN", response.body.access_token)
client.global.set("REFRESH_TOKEN", response.body.refresh_token)
%}
### Hello World from Sparebank1
GET https://api.sparebank1.no/common/helloworld
Authorization: Bearer {{ACCESS_TOKEN}}
Accept: application/vnd.sparebank1.v1+json; charset=utf-8
### Fetch all accounts
GET {{bankingBaseUrl}}/accounts
Authorization: Bearer {{ACCESS_TOKEN}}
### Fetch all transactions of specific days (inclusive)
GET {{bankingBaseUrl}}/transactions?accountKey={{brukskontoAccountKey}}&fromDate=2025-01-20&toDate=2025-01-22
Authorization: Bearer {{ACCESS_TOKEN}}
Accept: application/vnd.sparebank1.v1+json; charset=utf-8