0

So basically: I have used google oauth2 to be able to login the user with google classroom api scopes (such as classroom.courses.readonly) using the react-google-login module. However: how would I get data such as the user's courses/student rosters in those courses?

FYI: I'm trying to get a list of the user's courses and lists of the students inside those courses. I would appreciate any help given, I've been working on this issue for many days now.

Heres the React code:

import GoogleLogin from 'react-google-login';

const clientID = process.env.REACT_APP_CLIENT_ID;

const onGoogleSuccess = (res) => {
    console.log(res);
    window.localStorage.setItem('token', res.tokenId);
}
<GoogleLogin 
    clientId={clientID}
    buttonText="Login"
    onSuccess={onGoogleSuccess}
    cookiePolicy="single_host_origin"
    scope="openid https://www.googleapis.com/auth/classroom.courses.readonly"
    isSignedIn={true}
/>
3
  • Maybe this will be of help to you? stackoverflow.com/questions/51977448/how-to-use-gapi-in-react Commented May 18, 2021 at 7:28
  • @RafaGuillermo How would I use that with google classroom api tho? I tried using the googleapis npm module in react but it uses fs so it throws an error. Commented May 22, 2021 at 14:06
  • What error does it throw and what code throws it? Commented May 24, 2021 at 7:14

1 Answer 1

0

You can use the react-gapi library

Sign up to request clarification or add additional context in comments.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.