octokit.graphql.net
octokit.graphql.net copied to clipboard
How to get current authorized organizations.
I am trying this:
var expression = query.Viewer.Organizations(2).Compile().
I authorise one of my organisations to be allowed but not the other. In this case the above code throws the exception:
"message":"GraphQL.ExecutionError: Error trying to resolve setupCallback. ---> Octokit.GraphQL.Core.Deserializers.ResponseDeserializerException: Although you appear to have the correct authorization credentials,\nthe
jplayerorganization has enabled OAuth App access restrictions, meaning that data\naccess to third-parties is limited.
I don't want to give jplayer organisation access but I want to give my other organisation access.
How do I get the current authorised organisations that the user has authorised instead of all of them?
@gjtorikian @d12 @nickvanw this appears to be a server-side GraphQL question more than client side, so I'm going to pass it on to you ;)
I'm ashamed to say that I don't think such a filtering exists. I'll open an issue internally at GitHub for this. Sorry about that!
I do believe this issue ought to be closed in the meantime, since it's not specific to this project. We will try to reply to this issue once a fix goes in.
Actually, on second glance -- I ran a similar query:
{
viewer {
organizations(first: 10) {
nodes {
repositories(first: 10) {
nodes {
name
}
}
}
}
}
}
I thought that the entire query would throw an exception, but that appears not to be the case. We return data for organizations which can return data, and we pass a message to errors if an organization has the OAuth App restrictions enabled.
If the entire query is failing, then that indicates some behavior that needs to be fixed in this project, I think.
Ah thanks @gjtorikian - yes that does actually sound like a problem with octokit.graphql then!
I think we treat all errors as meaning the query failed. I guess we need a way to allow "partial" errors on a query, though I'm not sure how this should be exposed to the client?
Yes, this is definitely an issue with this project.
Yes, we need a way to get around this issue. I'm not sure what a good API to represent a "partial success" would be however.
Maybe something like this?
Task<T> Run<T>(
this IConnection connection,
IQueryableValue<T> expression,
out Exception errors,
CancellationToken cancellationToken = default)
Where errors will be filled with an AggregateException if >1 errors occur?
or perhaps:
Task<(T, Exception)> RunAllowingPartialExceptions<T>(
this IConnection connection,
IQueryableValue<T> expression,
CancellationToken cancellationToken = default)
But we'd need a better name than RunAllowingPartialExceptions ;)
Thoughts on this would be appreciated.
@StanleyGoldman pokes @MartinDawson: Psst, I think he was asking you. 😅
@StanleyGoldman @grokys I gave a thumbs up that either looked good.
I am not a C# expert so I can't really say more.
Ah, no worries then. It's just the two of us making decisions so sometimes it helps to hear from someone else what looks or feels better.
This answer may be of use
HI @ENikS, the link no longer works can you please repost