मैंने यहां दिए गए उदाहरण की कोशिश की।थ्रेड "मुख्य" com.google.api.client.auth.oauth2 में अपवाद। टोकन रेस्पॉन्स अपवाद: 401 अनधिकृत
Exception in thread "main" com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized
at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)
at com.google.api.client.auth.oauth2.Credential.executeRefreshToken(Credential.java:570)
at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489)
at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:868)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at SheetsQuickstart.main(SheetsQuickstart.java:106)
मैं इसे करने के लिए सभी आवश्यक अनुमति दी हुई है -
https://developers.google.com/sheets/quickstart/java
इसका मुझे इस अपवाद देने।
मैं उपयोग कर रहा हूँ चादर एपीआई संस्करण v4
अपडेट -
अगर मैं उदाहरण में email id
गुजर रहा बजाय user
तो इसकी मुझे इस प्रतिक्रिया दे रहा है।
परिवर्तन -
public static Credential authorize() throws IOException {
// Load client secrets.
InputStream in =
SheetsQuickstart.class.getResourceAsStream("/client_secret.json");
GoogleClientSecrets clientSecrets =
GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(DATA_STORE_FACTORY)
.setAccessType("offline")
.build();
//Changed Part.
Credential credential = new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize("[email protected]");
System.out.println(
"Credentials saved to " + DATA_STORE_DIR.getAbsolutePath());
return credential;
}
प्रतिक्रिया -
Name, Major
Alexandra, English
Andrew, Math
Anna, English
Becky, Art
Benjamin, English
Carl, Art
Carrie, English
Dorothy, Math
Dylan, Math
Edward, English
Ellen, Physics
Fiona, Art
John, Physics
Jonathan, Math
Joseph, English
Josephine, Math
Karen, English
Kevin, Physics
Lisa, Art
Mary, Physics
Maureen, Physics
Nick, Art
Olivia, Physics
Pamela, Math
Patrick, Art
Robert, English
Sean, Physics
Stacy, Math
Thomas, Art
Will, Math
मैं हल करने 400 - Unable to parse range: Class Data!A2:A4"
@pnuts ध्यान के लिए धन्यवाद। मैंने उस टैग को हटा दिया है। –