authgear / authgear/authgear-server

[SDK] Introduce getOrRefreshAccessToken and deprecate refreshAccessTokenIfNeeded

Open
#3,655 0 comments 0 reactions 0 assignees View on GitHub
pitch
Dominant language
Go
Stars
2k
Forks
125
Avg merge
2d 17h
Merged PRs (30d)
32

Description

## Problem

- The original function in SDK "refreshAccessTokenIfNeeded" has a confusing name and not easy to understand behavior

## Appetite

2 week

## Solution

- Introduce new function "getOrRefreshAccessToken" and mark "refreshAccessTokenIfNeeded" deprecated in the SDK for each platform
- The new function should always either return a valid access token, or throw an exception
- the access token is returned in the form of value, callback class, or promise etc, according to the conventions of the platform e.g. JavaScript, a promise. On Android a callback class. On iOS a completion handler.
- Error handling in doc:
- The new API references and docs should make it simple for developers users to reference all of the exception cases. Including:
- IOException, or
- Users is not logged in, or
- refresh tokens not exists etc.

## Todo

- Update SDK
- [ ] iOS
- [ ] Android
- [ ] JS
- [ ] Web
- [ ] RN
- [ ] Capacitor
- [ ] Flutter
- [ ] Xamarin
- [ ] Update Tutorial
- [ ] Replace all refreshAccessTokenIfNeeded usage with getOrRefreshAccessToken
- [ ] Make sure all exception cases are described in the API references for all platforms
- [ ] Link the doc to the exception cases for all platforms

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by locating each platform SDK's refreshAccessTokenIfNeeded definition and its usages, then review the related API references and tutorials. Done means the new getOrRefreshAccessToken API exists across the listed platforms, the old API is deprecated, usages are replaced, and documented exception cases are linked for each platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, flutter, ios, javascript
Domain
api, authentication, documentation, mobile-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.