Skip to content

Automatic google login with username and password #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 28, 2016
Merged

Automatic google login with username and password #265

merged 3 commits into from
Jul 28, 2016

Conversation

svarzee
Copy link
Contributor

@svarzee svarzee commented Jul 27, 2016

Changes made:

  • Added gpsoauth dependency
  • Created a credential provider that can be used with username and password and doesn't require manual interaction

@Grover-c13
Copy link
Owner

nice

@FabianTerhorst
Copy link
Collaborator

nice library you found there.

@FabianTerhorst
Copy link
Collaborator

@svarzee are you sure the jar is added correctly? Travis build is failing, because of missing package.

@svarzee
Copy link
Contributor Author

svarzee commented Jul 27, 2016

@FabianTerhorst hmm, I'll figure it out tomorrow, I haven't slept for a night to port gpsaouth

@svarzee svarzee closed this Jul 27, 2016
@svarzee svarzee reopened this Jul 27, 2016
@svarzee svarzee closed this Jul 27, 2016
@svarzee svarzee reopened this Jul 27, 2016
@vmarchaud
Copy link
Contributor

vmarchaud commented Jul 27, 2016

I dont see any refresh token method in your lib, you should implement it so dont store in RAM the google credentials.
Plus we are using gradle, i think you should make a jitpack like us to host it somewhere.

@rajulbhatnagar
Copy link
Contributor

rajulbhatnagar commented Jul 27, 2016

I guess this makes it convenient so its a good option to have in the API. But I personally dont like it too much as I am not comfortable entering google login credentials for people using primary accounts.

And it does not work with 2 factor authentication. Also I dont see any library implement token refresh :/ rather than re-logging in generating a new master token

@Grover-c13
Copy link
Owner

i think it really depends on your use case: if your providing a service that uses its own accounts (like a pokemon scanning map) automated login would be best for them for load balancing, but anything that uses other peoples accounts should be using oauth imo.

@Grover-c13
Copy link
Owner

Grover-c13 commented Jul 27, 2016

and yes it really does need refreshing.

@rajulbhatnagar
Copy link
Contributor

Well its still oauth. Just someone was able to extract the master token from an old version google play services which allows us to act like the googleapiclient

@rajulbhatnagar
Copy link
Contributor

Hmm looking at the library code it looks like the mastertoken should be usable as a refresh token.

@Grover-c13
Copy link
Owner

yeah, by that i mean interfacing with users should use proper oauth flows (ie the username and password never enter the java api)

@svarzee
Copy link
Contributor Author

svarzee commented Jul 27, 2016

I used the master token to refresh auth token.

@AbandonedCart
Copy link
Collaborator

AbandonedCart commented Jul 28, 2016

While I see the drawbacks of having the user enter their credential information, this would be extremely beneficial to Android. On Android, there are means to have the user approve the app to access accounts, meaning it could enter the username and have them enter a password without the actual app caching them locally. This would only be desired as a secondary method, though.

The most significant issue I have had with API usage has been effectively displaying the required views to have the user perform their manual steps in the process of an AsyncTask and then actually having them understand exactly how and why they had to log in with a website and enter a code.

Unfortunately, building failed when this change was included until a line length issue was resolved, but then caused building of the target application to fail. The error for that failure is included below:

[dx] UNEXPECTED TOP-LEVEL EXCEPTION: [dx] java.lang.RuntimeException: Exception parsing classes [dx] at com.android.dx.command.dexer.Main.processClass(Main.java:752) [dx] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:718) [dx] at com.android.dx.command.dexer.Main.access$1200(Main.java:85) [dx] at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645) [dx] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) [dx] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) [dx] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) [dx] at com.android.dx.command.dexer.Main.processOne(Main.java:672) [dx] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574) [dx] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311) [dx] at com.android.dx.command.dexer.Main.run(Main.java:277) [dx] at com.android.dx.command.dexer.Main.main(Main.java:245) [dx] at com.android.dx.command.Main.main(Main.java:106) [dx] Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000) [dx] at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472) [dx] at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406) [dx] at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388) [dx] at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251) [dx] at com.android.dx.command.dexer.Main.parseClass(Main.java:764) [dx] at com.android.dx.command.dexer.Main.access$1500(Main.java:85) [dx] at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684) [dx] at com.android.dx.command.dexer.Main.processClass(Main.java:749) [dx] ... 12 more [dx] 1 error; aborting

@Grover-c13 Grover-c13 merged commit 79e0d99 into Grover-c13:Development Jul 28, 2016
@benjy3gg
Copy link

can you add a quick example code?

@Grover-c13
Copy link
Owner

GoogleAutoCredentialProvider cre = new GoogleAutoCredentialProvider(http, "username", "password");
PokemonGo go = new PokemonGo(cre, http, time);``

@benjy3gg
Copy link

benjy3gg commented Jul 28, 2016

the Time object can be
new Time() { @Override public long currentTimeMillis() { return System.currentTimeMillis(); } }
?

@Grover-c13
Copy link
Owner

Use SystemTimeImpl by default

@benjy3gg
Copy link

benjy3gg commented Jul 28, 2016

done.
Im on android and when i try to compile i get:
Unsupported class file version 52.0

@Paul776
Copy link

Paul776 commented Jul 28, 2016

This causes my Android build to break

Error:Execution failed for task ':app:transformClassesWithJarMergingForLiteDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/Address.class

Even If I exclude okio I get same error, anyone using it with android has the same problem ?

@AbandonedCart
Copy link
Collaborator

The issue is gpsoauth-java.

The build.gradle declares sourceCompatibility = 1.8 and should be sourceCompatibility = 1.7 to resolve this error.

@benjy3gg
Copy link

where exactly?

@AbandonedCart
Copy link
Collaborator

@Paul776
Copy link

Paul776 commented Jul 28, 2016

Thanks!

@Paul776
Copy link

Paul776 commented Jul 28, 2016

However now I get this while performing the login
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/util/Base64;
which is a java8 class

@AbandonedCart
Copy link
Collaborator

AbandonedCart commented Jul 28, 2016

http://stackoverflow.com/a/14413290/461982

But that does not support url encoding, so it isn't a complete solution

@Paul776
Copy link

Paul776 commented Jul 28, 2016

I tried by adding apache common codec and using Base64 from there to encode in 64 for it to work with java 7

but the login does not work.

@AbandonedCart
Copy link
Collaborator

AbandonedCart commented Jul 28, 2016

Updated the PR using a refactored Android Base64, but bear in mind

CRITICAL

Not to mention it would appear Niantic has disabled new auth requests temporarily. It is uncertain if this is related to the excessive permissions issue or a permanent change, though.

@Paul776
Copy link

Paul776 commented Jul 28, 2016

Thanks for this, yes it appears I'm having trouble log-in at the moment. I will give it a go later!

@AbandonedCart
Copy link
Collaborator

Worst case is having to start doing auth as an iPhone. The premise being that they can't completely remove auth requests without completely redesigning iOS support.

@Paul776
Copy link

Paul776 commented Jul 28, 2016

Have you ever managed to login successfully using this pull request ? I'm always getting 403

@benjy3gg
Copy link

i cant get token too. 403

@Paul776
Copy link

Paul776 commented Jul 28, 2016

It is a problem with the lib somewhere as I have made a python script the can get me the token without problem.
@svarzee when you wake up from your siesta could you have a look?

Thanks for the lib by the way!

@AbandonedCart
Copy link
Collaborator

They are currently blocking the auth requests. It's not a local issue.

@benjy3gg
Copy link

are you sure @LoungeKatt ?

@AbandonedCart
Copy link
Collaborator

Yes

@benjy3gg
Copy link

is this login method different from the login method use in the app?

@Grover-c13
Copy link
Owner

The automated one is the closest to the app.

@AbandonedCart
Copy link
Collaborator

AbandonedCart commented Jul 28, 2016

It still isn't an identical request. If the basis for your question is that you can log in using the app and not using the API, then it is important to remember that you are not signing with Niantic's keys.

Blocking third-party requests, by definition, blocks requests made outside the scope of the app itself.

You can verify this by testing the original, "manual" oath process. That is currently unavailable, as well.
If there are still doubts, the same can be achieved by attempting to log in using an iPhone and Google.
Google login using an iPhone is an official request, signed by Niantic, but simply sits on loading.

@benjy3gg
Copy link

okay... you think it will be possible to login again sometime soon?

@benjy3gg
Copy link

so you cant login with iphone into the official app right now over google login?

@john086
Copy link

john086 commented Jul 28, 2016

There are news ? about instant run android ?

Any idea?

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.

@AbandonedCart
Copy link
Collaborator

@benjy3gg That about sums it up.

@john086 svarzee/gpsoauth-java#1

Grover-c13 added a commit that referenced this pull request Aug 1, 2016
* Refresh the OAuth token when it expires

* Fix my siliness and provide API consumers a way to provide their refresh token when using static auth

* add query from hatched eggs + rewrite stuff around EggPokemon

* fix the explaination for eclipse user

* Level enum public for custom loggers

* Publish sources jar

Fixes #128

* add license to GoogleLoginSecrets

* Use a reset instead of using another instance

* Fix the checkstyle config to not break other modules

* find Pokemon by ID
update inventory after hatching eggs
add missing license

* Meta info on pokemon

* add method the incubator

* fix typo

* Add a callback for when the Initial oAuth completes so that the app can automate the flow

* Power up pokemon API

* Add info about native google sign in

* REAME.md: fix Usefull->Useful typo

* README.md: fix PtcLogin classname type

* fix force updating inventories

* Fix incorrect static statements on point

* Added iv calculator (#207)

* Added iv calculator

* checkstyleMain fix

* Fix @returns in doc of getIVRatio()

* take care that the candies actually are in the map

* forgot that cancerous check style

* tweak checkstyle config to be friendly (#226)

* Add cause to LoginFailedExceptions. (#220)

Signed-off-by: Niklas Walter <[email protected]>

* Remove printStackTrace from updateProfile (#221)

updateProfile, in case of failure, would dump stacktraces to the console and then crash in the next line with a NullPointerException

* Added request to add modifiers to forts, for example a lure-module on a pokestop (#217)

* implemented request to add fort modifier

* added @throws to javadoc for addModifier in Pokestop.java

* Added SetFavoritePokemon method (#222)

* add lombok to more objects (#212)

* add lombok to more objects

* add lombok to GoogleAuthJson

* add lombok to Team

* getItemsCount function (#224)

* get total space used by items

* get total space used by items

* add javadoc

* Rewrote and Refactored login logic. Now the credential providers transparently handle providing credentials and refreshing tokens.

* Update the protobuf dependency (#235)

Includes fix for hatched eggs IndexOutOfBoundsException

* WIP: Gym/Battle (#203)

* Add info about native google sign in

* fix force updating inventories

* REAME.md: fix Usefull->Useful typo

* README.md: fix PtcLogin classname type

* Start Gym + Battle API

* Battle API - Example included, utility functions to get state of battle. Can only spam attack right now.

* Deprecate pokemon.getFavorite, rename to pokemon.isFavorite (#230)

* deprecate getFavorite, rename to isFavorite

* Adhere to checkstyle

* Use gradle-wrapper instead (#200)

* Use gradle-wrapper instead

* Changed second gradle usage to use gradlew aswell

* Fix typos (#218)

* Fix UTF-8 encoding

* Fix typo recieved -> received

* fix example

* Consistently use RemoteServerException for network/server errors (#243)

* Redone meta pm, lots of info available, several enums for pokemon (some may be duplicates of proto enums), fix catchable pokemon (#246)

* fix #237 + #227 (#240)

* Update protobufs to latest version

* Add getPoints() to gym wrapper (#247)

* Fix #171 - Implement logging levels

* Hypno should actually be in FAMILY_DROWZEE (#262)

* Update README.md (#257)

Clarification on what the function calls do. If we're going to change the API wrapper, we should at least briefly comment on how it works underneath.

* added the ability to use potions & revive on pokemon (#236)

* inizio pozioni pokemon

* inizio pozioni pokemon

* fixed space

* checkstyle fixes

* refresh pokemon stamina after heal/revive

* added a request to accept level up rewards and unlocks (#259)

* Fix silly error

* Rewrite readme with all new stuff

- explain the risk of using this api
- more examples
- got to jitpack to build with maven/graddle
- update contributor

* abstract time behavior to allow mocking and replacing the time by non-System time (#277)

* set time implementation correctly (#282)

make old PtcCredentialProvider constructor @deprecated

* settings via DownloadSettings + protobuf update (#285)

* inizio pozioni pokemon

* inizio pozioni pokemon

* fixed space

* checkstyle fixes

* refresh pokemon stamina after heal/revive

* add support for settings

* add support for settings

* Added CP based calculations (#272)

* Added CP based calculations

* Implemented method instead of lookup

* Added check if meta info exists. Swapped map

* #272 (comment)

* Add usage instructions for Eclipse users (#290)

Many will opt for simply copying the lib to the libs folder, but this
allows building the API project as necessary, while maintaining an
updated version of the lib produced in the target project.
** Intended for only building the target project with Eclipse **

* fix for #279 (#292)

* check and equip badges

* check and equip badges

* Automatic google login with username and password (#265)

* Add gpsoauth dependency

* Add google auto credentials provider

* Add token refresh

* svarzee-Development (#297)

* Add gpsoauth dependency

* Add google auto credentials provider

* Add token refresh

* Checkstyle will not stop you building now, but you are still expected to correct issues before submitting a PR. (#300)

* Checkstyle will not stop you building now, but you are still expected to correct issues before submitting a PR.

fixed issue with checkstyle in google auto login.

* Checkstyle fix

* gdev (#305)

* Checkstyle will not stop you building now, but you are still expected to correct issues before submitting a PR.

fixed issue with checkstyle in google auto login.

* Checkstyle fix

* Added time to new provider

* added time

* added PokemonMoveMeta + Registry (#298)

* created PokemonMoveMeta.java

* added PokemonMoveMetaRegistry

* Update PokemonType.java

* modify build process to generate javadoc and one bundled jar + fix checkstyle (#307)

* add javadoc link to readme

* Added weight getter to Pokemon.java (#309)

* trigger bundle after creating the jar

* bundle is done for every build now

* Added new oauth for google user interaction to supercede GoogleCredentialProvider (example included) added a new hasLure method to Pokestops that is more reliable. Undeprecrated constructors that construct time objects by default (#316)

* delete old google token provider since its working + add explain on example

* Correct, organize, and format README

- Correct spelling, grammar, and punctuation errors
- Format lists into individual steps
- Break comments into smaller segments
- Simplify complex explanations

* fix styles

* Update the readme example to use the latest google provider

* add javadoc

* added getter to get refresh token for GoogleAutoProvider + constructor without Time impl in GoogleUserProvider

* Feature request Issue 311

* - replaced for loop by iterator because of concurrent modification in MapObjects Update method

* update readme with slack invitation link

* hotfix spamming request when constructing PokemonGo instance

* test

* test

* -also changed update method of gyms to use iterator

* Upgrade gpsoauth

* - fixed styling

* Cleaned up some doc blocks (#352)

* Added Util class to get Name for Pokedex Numbers, Also added Translations (#284)

* Added Util class to get NAme for Pokedex Numbers, Also added Translations for those

* Adjusted Files According to Pullrequest Review

* Removed Double License Headeer, Added Missing License Header

* Fixed hasLurePokemon() from always returning false unless the lure module expired and the pokestop was still in memory with a pokemon. It now properly returns true if there is a pokemon at the pokestop and the lure is not expired.

* Async implementation based in Futures (#360)

* Base for async

* Transparent async requests

* Converted map

* Converted map, may have broken cache

* Cleanup leftovers of Rx

* Start on catchable pokemon

* Did some methods on CatchablePokemon. Implemented NestedFutureWrapper to link Futures

* Switched Pokestop

* Some tinkering with timings and forgetting to clear lists

* Exceptions shoudl accept Throwable

* Cleanup of deprecate methods,
Removed sleeps

* Fixed sending garbage

* Actually got it working

* Checkstyle update

* Checkstyle update

* Upped timer a bit because of a few issues with empty requests

* Sync list (#370)

* Add moves to pokemon meta registry (#368)

* Fix get catchablePokemon (#386)

* Sync list

* Hopefully fix map.getObject/getCatchablePokemon issue

* Make constructor lightweight (#388)

* Sync list

* Hopefully fix map.getObject/getCatchablePokemon issue

* Refactor some player profile stuff, make the constructor shorter, made it lazy init (wont call for an update on the server unless you call a method to get data)

* The api constructor will not make any server requests, it will lazy load any sections of the api a person needs (ie callling getInventories will get stuff from the server if its yet to happen). Some extra methods now throw RemoteServer/Login exceptions so please keep that in mind. cleaned up a few things (mainly javadoc).

* Refactor some player profile stuff, make the constructor shorter, made it lazy init (wont call for an update on the server unless you call a method to get data)

* Implemented inventory settings (#376)

* added support for incense activation (#314)

* Changed private fields to protected to allow extending of the Providers for API users without having to rewrite the whole class. (#350)

* Optimize imports (#390)

* Optimize imports

* Optimize imports

* added Japanese pokemon names and fixed garbled characters in Russian and Chinese (#383)

* Fort details should be doubles instead of longs (#393)

* #378 (#392)

* Fix import.*, fix other checkstyle stuff, fix NPE when getting stats (#401)

* Add evolution auxiliaries (#400)

* fix infinite loop when pokemon flees using catch(), removed pokemon from catchable list after being caught/fleeing

* fix infinite loop when pokemon flees using catch(), removed pokemon from catchable list after being caught/fleeing

* catchfix (#404)

* fix infinite loop when pokemon flees using catch(), removed pokemon from catchable list after being caught/fleeing

* fix infinite loop when pokemon flees using catch(), removed pokemon from catchable list after being caught/fleeing

* Lucky egg for spinnix yay

* useLuckyEgg() in ItemBag for spinnix,
Fix NPE on catch result
Fix issue when pokemon broke out of ball
Fix checkstyle issues

* Remove print

* Fixes an ArrayOutOfBoundsException (#411)

Fixes an ArrayOutOfBoundsException in EvolutionInfo.
Currently it takes the length of an array as an index in the array which will result in an exception being thrown anytime this function is called.

* Extra log levels: all and none (#409)

* Extra log levels: all and none

* Fix indentation (tabs only)

* Adding Sorting Map Objects (#396)

* Adding map util to get distance between two points

* Adding sorting function for objects in the map

* Adding the check if the user have enough poke ball´s

* Adding the check if the user have enough poke ball´s

* Adding license

* Fixing example class

* Fix code style

* Updating code style

* Updating code style

* Fixing import

* luresfixesandgoodtimes (#418)

* Added lured pokemon to getCatchablePokemon
removed DummyFuture
Fixed NPE in FutureWrapper when using .just
Fixed issue when caught pokemon will still appearing in catchable pokemon
Added a little more detail to the PTC login exception
Changed exception message from "Error in url" to "Invalid auth status code recieved"

* Checkstyle

* Travis fix

* updated moves (#416)

https://www.reddit.com/r/TheSilphRoad/comments/4v99uo/move_powers_have_been_updated/

* Adding the check if the user have enough poke ball´s (#397)

* Adding the check if the user have enough poke ball´s

* Adding the check if the user have enough poke ball´s

* Fixing example class

* Fix code style

* updating submodule to latest (#419)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants