You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Google OAuth 2.0 Authorization Framework to obtain Github Access Token. It throw the following exception.
Exception in thread "main" java.lang.IllegalArgumentException:
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:889)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:382)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:355)
at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:87)
at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:81)
at com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:459)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)
at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.authorize(AuthorizationCodeInstalledApp.java:82)
at com.techoffice.Appl.authorize(Appl.java:61)
at com.techoffice.Appl.main(Appl.java:68)
Caused by: java.lang.IllegalArgumentException: expected numeric type but got class com.google.api.client.auth.oauth2.TokenResponse
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:844)
... 9 more
The below would be my partial source code.
private static Credential authorize() throws IOException {
AuthorizationCodeFlow flow = new AuthorizationCodeFlow.Builder(BearerToken.authorizationHeaderAccessMethod(),
HTTP_TRANSPORT, JSON_FACTORY, new GenericUrl(TOKEN_SERVER_URL),
new ClientParametersAuthentication(clientId, clientSecret), clientId, AUTHORIZATION_SERVER_URL)
.setScopes(Arrays.asList(SCOPE)).setDataStoreFactory(DATA_STORE_FACTORY).build();
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setHost(LOCALHOST).setPort(PORT).build();
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
}
access_token=e72e16c7e42f292c6912e7710c838347ae178b4a&scope=user%2Cgist&token_type=bearer
Google OAuth would support JSON Format. To make Github response in JSON format, it required to add Accept: application/json in header.
How can I make it support in Github?
The text was updated successfully, but these errors were encountered:
I am using Google OAuth 2.0 Authorization Framework to obtain Github Access Token. It throw the following exception.
The below would be my partial source code.
I found the response of https://github.com/login/oauth/access_token would be in
access_token=e72e16c7e42f292c6912e7710c838347ae178b4a&scope=user%2Cgist&token_type=bearer
Google OAuth would support JSON Format. To make Github response in JSON format, it required to add Accept: application/json in header.
How can I make it support in Github?
The text was updated successfully, but these errors were encountered: