Skip to content

[Feature Request] Json encoding for authorization token rotation #2451

@PhilipGrefe

Description

@PhilipGrefe

When using Supabase Auth, the standard supabase endpoint to rotate tokens only accepts 'Content-Type': 'application/json'. Requests with content type ´application/x-www-form-urlencoded` fail with the following response:

{status: 400, response: null, error: '{"code":400,"error_code":"bad_json","msg":"Could not parse request body as JSON: unexpected end of JSON input"}', success: false}

The current docs only show POST requests with Form content type.
Would it be possible to add an option to send the refresh token request using application/json, and using an object in the payload instead of form data?


Sample Config

authorization: {
  accessToken: session.access_token,
  strategy: BackgroundGeolocation.AuthorizationStrategy.Jwt,
  expires: session.expires_in,
  refreshToken: session.refresh_token,
  refreshUrl: supabaseUrl + '/auth/v1/token?grant_type=refresh_token', // <--- default supabase endpoint to refresh tokens
  refreshHeaders: {
    apikey: supabaseKey,
    'Content-Type': 'application/json',
  },
  refreshPayload: {
    refresh_token: '{refreshToken}',
  },
  refreshEncoding: BackgroundGeolocation.Encoding.JSON, // <--- sommething like this
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions