How to replace AuthorizationCodeInstalledApp class?App crashes and gives NullPointerException error when trying to set up Gmail API for AndroidHow do I efficiently iterate over each entry in a Java Map?Java inner class and static nested classHow do save an Android Activity state using save instance state?How slow are Java exceptions?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?
Can an old DSLR be upgraded to match modern smartphone image quality
My player wants to cast multiple charges of magic missile from a wand
Differences between “pas vrai ?”, “c’est ça ?”, “hein ?”, and “n’est-ce pas ?”
What are the slash markings on Gatwick's 08R/26L?
SPI on stm32 won't work without pullup resistors and even then performs poorly
Why would Lupin kill Pettigrew?
Is there an explanation for Austria's Freedom Party virtually retaining its vote share despite recent scandal?
Self-Preservation: How to DM NPCs that Love Living?
What is game ban VS VAC ban in steam?
When a current flow in an inductor is interrupted, what limits the voltage rise?
How can I offer a test ride while selling a bike?
If a problem only occurs randomly once in every N times on average, how many tests do I have to perform to be certain that it's now fixed?
How can I prevent interns from being expendable?
Is the world in Game of Thrones spherical or flat?
Modern approach to radio buttons
If Sweden was to magically float away, at what altitude would it be visible from the southern hemisphere?
What are the problems in teaching guitar via Skype?
What was this black-and-white film set in the Arctic or Antarctic where the monster/alien gets fried in the end?
What is/are this/these giant NASA box(es)?
What is the indigenous Russian word for a wild boar?
How was Apollo supposed to rendezvous in the case of a lunar abort?
Adding strings in lists together
Why is there a need to modify system call tables in linux?
Is there a rule that prohibits us from using 2 possessives in a row?
How to replace AuthorizationCodeInstalledApp class?
App crashes and gives NullPointerException error when trying to set up Gmail API for AndroidHow do I efficiently iterate over each entry in a Java Map?Java inner class and static nested classHow do save an Android Activity state using save instance state?How slow are Java exceptions?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to run sample code from Google Quickstart for Java on an Android emulator, but the code falls on this line
return new AuthorizationCodeInstalledApp(flow, receier).authorize("user");
It turned out that Android does not support AuthorizationCodeInstalledApp
class, so you need to manually catch the URL address for authorization, open it in the browser and then put the result in the Credential
object. I am familiar with Java superficially, so I don't really know how I can implement that.
Can you please tell how this can be done?
java android google-sheets-api
add a comment |
I am trying to run sample code from Google Quickstart for Java on an Android emulator, but the code falls on this line
return new AuthorizationCodeInstalledApp(flow, receier).authorize("user");
It turned out that Android does not support AuthorizationCodeInstalledApp
class, so you need to manually catch the URL address for authorization, open it in the browser and then put the result in the Credential
object. I am familiar with Java superficially, so I don't really know how I can implement that.
Can you please tell how this can be done?
java android google-sheets-api
add a comment |
I am trying to run sample code from Google Quickstart for Java on an Android emulator, but the code falls on this line
return new AuthorizationCodeInstalledApp(flow, receier).authorize("user");
It turned out that Android does not support AuthorizationCodeInstalledApp
class, so you need to manually catch the URL address for authorization, open it in the browser and then put the result in the Credential
object. I am familiar with Java superficially, so I don't really know how I can implement that.
Can you please tell how this can be done?
java android google-sheets-api
I am trying to run sample code from Google Quickstart for Java on an Android emulator, but the code falls on this line
return new AuthorizationCodeInstalledApp(flow, receier).authorize("user");
It turned out that Android does not support AuthorizationCodeInstalledApp
class, so you need to manually catch the URL address for authorization, open it in the browser and then put the result in the Credential
object. I am familiar with Java superficially, so I don't really know how I can implement that.
Can you please tell how this can be done?
java android google-sheets-api
java android google-sheets-api
edited Mar 24 at 9:57
Fantômas
33.1k156492
33.1k156492
asked Mar 24 at 9:37
Михаил ЕршовМихаил Ершов
61
61
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
From this thread, Charan M uses this piece of code to get credential and service:
mCredential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff());
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
mService = new com.google.api.services.gmail.Gmail.Builder(
transport, jsonFactory, credential)
.setApplicationName(mContext.getResources().getString(R.string.app_name))
.build();
Do note that you can't run this code on the main thread since it involves network operations. They also provided a github project as a guide in integrating, in their case, Gmail API into their Android project.
Why I can't get account name then I already have mCredential? I mean, that GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff()); Log.v("states", credential.getSelectedAccountName()); will give me a error. Am I do smth wrong?
– Михаил Ершов
Mar 25 at 18:05
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322422%2fhow-to-replace-authorizationcodeinstalledapp-class%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
From this thread, Charan M uses this piece of code to get credential and service:
mCredential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff());
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
mService = new com.google.api.services.gmail.Gmail.Builder(
transport, jsonFactory, credential)
.setApplicationName(mContext.getResources().getString(R.string.app_name))
.build();
Do note that you can't run this code on the main thread since it involves network operations. They also provided a github project as a guide in integrating, in their case, Gmail API into their Android project.
Why I can't get account name then I already have mCredential? I mean, that GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff()); Log.v("states", credential.getSelectedAccountName()); will give me a error. Am I do smth wrong?
– Михаил Ершов
Mar 25 at 18:05
add a comment |
From this thread, Charan M uses this piece of code to get credential and service:
mCredential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff());
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
mService = new com.google.api.services.gmail.Gmail.Builder(
transport, jsonFactory, credential)
.setApplicationName(mContext.getResources().getString(R.string.app_name))
.build();
Do note that you can't run this code on the main thread since it involves network operations. They also provided a github project as a guide in integrating, in their case, Gmail API into their Android project.
Why I can't get account name then I already have mCredential? I mean, that GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff()); Log.v("states", credential.getSelectedAccountName()); will give me a error. Am I do smth wrong?
– Михаил Ершов
Mar 25 at 18:05
add a comment |
From this thread, Charan M uses this piece of code to get credential and service:
mCredential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff());
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
mService = new com.google.api.services.gmail.Gmail.Builder(
transport, jsonFactory, credential)
.setApplicationName(mContext.getResources().getString(R.string.app_name))
.build();
Do note that you can't run this code on the main thread since it involves network operations. They also provided a github project as a guide in integrating, in their case, Gmail API into their Android project.
From this thread, Charan M uses this piece of code to get credential and service:
mCredential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff());
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
mService = new com.google.api.services.gmail.Gmail.Builder(
transport, jsonFactory, credential)
.setApplicationName(mContext.getResources().getString(R.string.app_name))
.build();
Do note that you can't run this code on the main thread since it involves network operations. They also provided a github project as a guide in integrating, in their case, Gmail API into their Android project.
answered Mar 25 at 5:58
JacqueJacque
54419
54419
Why I can't get account name then I already have mCredential? I mean, that GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff()); Log.v("states", credential.getSelectedAccountName()); will give me a error. Am I do smth wrong?
– Михаил Ершов
Mar 25 at 18:05
add a comment |
Why I can't get account name then I already have mCredential? I mean, that GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff()); Log.v("states", credential.getSelectedAccountName()); will give me a error. Am I do smth wrong?
– Михаил Ершов
Mar 25 at 18:05
Why I can't get account name then I already have mCredential? I mean, that GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff()); Log.v("states", credential.getSelectedAccountName()); will give me a error. Am I do smth wrong?
– Михаил Ершов
Mar 25 at 18:05
Why I can't get account name then I already have mCredential? I mean, that GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff()); Log.v("states", credential.getSelectedAccountName()); will give me a error. Am I do smth wrong?
– Михаил Ершов
Mar 25 at 18:05
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322422%2fhow-to-replace-authorizationcodeinstalledapp-class%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown