Skip to content

Commit

Permalink
add checks for authprovider
Browse files Browse the repository at this point in the history
  • Loading branch information
reddyashish committed Apr 16, 2024
1 parent 4e0dad7 commit cb08cc7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/DynamoMLDataPipeline/DynamoMLDataPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ internal string ProductionCollectionID
// Id of the user sending the post request.
private string GetUserId()
{
return AuthUserInfoProvider.UserId;
return AuthUserInfoProvider?.UserId;
}

// Authorization token needed for the restsharp post request in this pipeline.
Expand Down
12 changes: 10 additions & 2 deletions src/DynamoMLDataPipeline/DynamoMLDataPipelineExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ public string UniqueId
public void Startup(StartupParams sp)
{
DynamoMLDataPipeline = new DynamoMLDataPipeline();
DynamoMLDataPipeline.AuthTokenProvider = (IOAuth2AccessTokenProvider)sp.AuthProvider;
DynamoMLDataPipeline.AuthUserInfoProvider = (IOAuth2UserIDProvider)sp.AuthProvider;
DynamoMLDataPipeline.DynamoVersion = sp.DynamoVersion;

if (sp.AuthProvider is IOAuth2AccessTokenProvider tokenProvider)
{
DynamoMLDataPipeline.AuthTokenProvider = tokenProvider;
}

if (sp.AuthProvider is IOAuth2UserIDProvider userIdProvider)
{
DynamoMLDataPipeline.AuthUserInfoProvider = userIdProvider;
}
}

public void Ready(ReadyParams sp)
Expand Down

0 comments on commit cb08cc7

Please sign in to comment.