Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions packages/gotrue/lib/src/gotrue_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,14 @@ class GoTrueClient {
jwt: _currentSession?.accessToken,
),
);
return OAuthResponse(provider: provider, url: res['url']);
final url = res['url'] as String?;
if (url == null) {
throw AuthException(
'OAuth provider did not return a URL. '
'Ensure the provider is enabled in your Supabase project.',
);
}
return OAuthResponse(provider: provider, url: url);
}

/// Unlinks an identity from a user by deleting it.
Expand Down Expand Up @@ -1254,12 +1261,15 @@ class GoTrueClient {
urlParams.addAll(queryParams);
}
if (_flowType == AuthFlowType.pkce) {
assert(
_asyncStorage != null,
'You need to provide asyncStorage to perform pkce flow.',
);
final storage = _asyncStorage;
if (storage == null) {
throw AuthException(
'asyncStorage is required for PKCE flow. '
'Provide a GotrueAsyncStorage implementation when initializing GoTrueClient.',
);
}
final codeVerifier = generatePKCEVerifier();
await _asyncStorage!.setItem(
await storage.setItem(
key: '${Constants.defaultStorageKey}-code-verifier',
value: codeVerifier,
);
Expand Down