Account restricted to google Classroom API

牧云@^-^@ 提交于 2020-04-30 05:17:05

问题


My collague and I have a C# WPF project, which manage courses in Google Classroom. We create the project in Google API platform. We are the owner of the project. Both have OAuth 2.0 Client IDs. (but it doesn't matter) I allow all of Classroom API's scope.

I am the domain admin of our Gsuite for Education. Google Classroom API is allowed in the domain.

He can login and use the program, there is not any error, every function is ok. I can't, because i got an error 400, invalid_request Account restricted.

I try with API Explorer, and this error occurs only when I would like to get the list of topics of a google classroom course.

Scope: https://www.googleapis.com/auth/classroom.topics https://www.googleapis.com/auth/classroom.topics.readonly openid

        txtLog.Text += "Try login to Google...\n"; 
        UserCredential credential;

        using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
        {

            // The file token.json stores the user's access and refresh tokens, and is created
            // automatically when the authorization flow completes for the first time.
            string credPath = "token.json";
            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                new string[] 
                { 
                    ClassroomService.Scope.ClassroomCourses, 
                    ClassroomService.Scope.ClassroomRosters, 
                    ClassroomService.Scope.ClassroomProfileEmails, 
                    ClassroomService.Scope.ClassroomProfilePhotos,
                    ClassroomService.Scope.ClassroomTopics
                },
                "admin",
                CancellationToken.None,
                new FileDataStore(credPath, true)).Result;
            txtLog.Text += $"Credential file saved to: {credPath}\n";
        }

        // Create Classroom API service.
        service = new ClassroomService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = "Jedlik Classroom Manager",
        });

        // Define request parameters.
        CoursesResource.ListRequest request = service.Courses.List();
        request.PageSize = 100;

        // List courses.
        ListCoursesResponse response = request.Execute();
        if (response.Courses != null && response.Courses.Count > 0)
        {
            txtLog.Text +=$"Number of coureses: {response.Courses.Count}\n";
            lstCourses.ItemsSource = response.Courses.ToList();
            lstCourses.DisplayMemberPath = "Name";
            lstCourses.SelectedValuePath = "Id";
            lstCourses.SelectedIndex = 0;
        }
        else
        { 
            txtLog.Text += $"No courses found\n";
        }

Any idea?


回答1:


Answer:

This sounds like a problem with your account. To get a resolution you should contact G Suite support.

More Information:

If there is an account restriction on the account trying to authenticate then this isn't something that the Stackoverflow community can help with - especially if the same code works for another teacher on your domain and that you are receiving the same response in the Try this API funciton on the courses.topics reference page.

You can contact G Suite Support using the links on this page

I know this is generally bad news, but I hope this is helpful to you!

References:

  • Google Classroom API - Method courses.topics
  • Contact G Suite support


来源:https://stackoverflow.com/questions/60929810/account-restricted-to-google-classroom-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!