Skip to content

Development #248

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 64 commits into from
Jul 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
ccf016d
Refresh the OAuth token when it expires
rajulbhatnagar Jul 23, 2016
7ccf228
Fix my siliness and provide API consumers a way to provide their refr…
rajulbhatnagar Jul 23, 2016
1ac8fa3
add query from hatched eggs + rewrite stuff around EggPokemon
vmarchaud Jul 23, 2016
1be9f75
fix the explaination for eclipse user
vmarchaud Jul 23, 2016
37a9850
Level enum public for custom loggers
Jari27 Jul 23, 2016
4ebe910
Publish sources jar
langerhans Jul 24, 2016
0db0742
Merge pull request #165 from rajulbhatnagar/googleauth_refresh
Grover-c13 Jul 24, 2016
69a5521
Merge pull request #169 from langerhans/lh/sources-jar
Grover-c13 Jul 24, 2016
5a7fcc4
Merge pull request #168 from Sadye/customloggers
Grover-c13 Jul 24, 2016
2a1fe2f
add license to GoogleLoginSecrets
jabbink Jul 24, 2016
995313a
Use a reset instead of using another instance
Hindi Jul 24, 2016
c7e4b65
Fix the checkstyle config to not break other modules
jabbink Jul 24, 2016
c954d6a
Merge pull request #177 from jabbink/fix/checkstyle
jabbink Jul 24, 2016
797f45e
Merge pull request #170 from jabbink/fix/licenseGoogleLoginSecrets
jabbink Jul 24, 2016
f544f80
Merge branch 'Development' of git://github.com/vmarchaud/PokeGOAPI-Ja…
jabbink Jul 24, 2016
80c8052
Merge branch 'vmarchaud-Development' into Development
jabbink Jul 24, 2016
562781f
find Pokemon by ID
jabbink Jul 24, 2016
c347392
Merge pull request #178 from jabbink/feature/fetchPokemonById
jabbink Jul 24, 2016
bf56011
Meta info on pokemon
Grover-c13 Jul 24, 2016
adab2ab
Merge pull request #179 from Grover-c13/Meta
Grover-c13 Jul 24, 2016
0aed3de
add method the incubator
vmarchaud Jul 24, 2016
6178463
fix typo
vmarchaud Jul 24, 2016
befed93
Add a callback for when the Initial oAuth completes so that the app c…
rajulbhatnagar Jul 24, 2016
3204bb7
Merge pull request #181 from rajulbhatnagar/gauth_hook
Grover-c13 Jul 24, 2016
f91890a
Merge pull request #180 from vmarchaud/Development
Grover-c13 Jul 24, 2016
4a91a97
Merge pull request #173 from Hindi/inventoryForceUpdate
Grover-c13 Jul 24, 2016
72ee8b7
Power up pokemon API
Grover-c13 Jul 24, 2016
1500ef9
Merge pull request #182 from Grover-c13/Meta
Grover-c13 Jul 24, 2016
49c9d7b
Add info about native google sign in
langerhans Jul 24, 2016
c2d302b
Merge pull request #184 from langerhans/patch-2
Grover-c13 Jul 24, 2016
5f37734
REAME.md: fix Usefull->Useful typo
lostgoat Jul 24, 2016
1a08b01
README.md: fix PtcLogin classname type
lostgoat Jul 24, 2016
34fc0e7
fix force updating inventories
jabbink Jul 24, 2016
742cc13
Merge pull request #190 from jabbink/fix/forceUpdateInventories
jabbink Jul 24, 2016
4831b9f
Merge pull request #187 from lostgoat/Development
Grover-c13 Jul 25, 2016
63670d0
Fix incorrect static statements on point
Jul 25, 2016
ccf1f7f
Merge pull request #202 from leelavery/Development
Grover-c13 Jul 25, 2016
82cd09f
Added iv calculator (#207)
sadye Jul 25, 2016
b2f6856
take care that the candies actually are in the map
vmarchaud Jul 25, 2016
efc490f
forgot that cancerous check style
vmarchaud Jul 25, 2016
6bf01f6
Merge pull request #225 from vmarchaud/Development
vmarchaud Jul 25, 2016
7b3662e
tweak checkstyle config to be friendly (#226)
vmarchaud Jul 26, 2016
4fb350f
Add cause to LoginFailedExceptions. (#220)
TwoStone Jul 26, 2016
612e3af
Remove printStackTrace from updateProfile (#221)
jabbink Jul 26, 2016
0d5e80e
Added request to add modifiers to forts, for example a lure-module on…
aschlosser Jul 26, 2016
1a44e76
Added SetFavoritePokemon method (#222)
Jul 26, 2016
b75a434
add lombok to more objects (#212)
FabianTerhorst Jul 26, 2016
3543350
getItemsCount function (#224)
ramarro123 Jul 26, 2016
3413809
Rewrote and Refactored login logic. Now the credential providers tran…
rajulbhatnagar Jul 26, 2016
89697f2
Update the protobuf dependency (#235)
jabbink Jul 26, 2016
76fb2b5
WIP: Gym/Battle (#203)
Grover-c13 Jul 26, 2016
b6dfe0c
Deprecate pokemon.getFavorite, rename to pokemon.isFavorite (#230)
sadye Jul 26, 2016
ce8829a
Use gradle-wrapper instead (#200)
RichoDemus Jul 26, 2016
1c5dec0
Fix typos (#218)
williamho Jul 26, 2016
8110d7b
Merge branch 'rewrote_login' of git://github.com/rajulbhatnagar/PokeG…
jabbink Jul 26, 2016
b1ef3e5
Fix UTF-8 encoding
jabbink Jul 26, 2016
c8f14e2
Fix typo recieved -> received
jabbink Jul 26, 2016
b77559c
fix example
jabbink Jul 26, 2016
819d02d
Merge pull request #234
jabbink Jul 26, 2016
24c67c1
Consistently use RemoteServerException for network/server errors (#243)
jabbink Jul 26, 2016
a64020a
Redone meta pm, lots of info available, several enums for pokemon (so…
Grover-c13 Jul 26, 2016
974a27a
fix #237 + #227 (#240)
vmarchaud Jul 26, 2016
271e47f
Update protobufs to latest version
jabbink Jul 26, 2016
7056682
Merge pull request #249 from jabbink/update/protobuf
vmarchaud Jul 26, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ You may open an issue also to request new features. Make sure you describe what
If you consider submitting a pull request, please note the following:

1. All pull requests **must** be submitted to the `Development` branch. The `master` branch is exclusively mutable by release. PRs against `master` will not be merged.
2. Pleae make sure you follow the projects code style. To make sure you did, you can use `./gradlew checkstyleMain`.
2. Please make sure you follow the projects code style. To make sure you did, you can use `./gradlew checkstyleMain`.
3. The project is licensed under [GNU GPLv3](../LICENSE.txt) thus all code you submit will be subject to this license.

## Contact
If you have any questions regarding the library you can ask those on the `#javaapi` channel on the [Pokemon GO Reverse Engineering Slack](https://pkre.slack.com/). You can [get your invite here](https://shielded-earth-81203.herokuapp.com/).
If you have any questions regarding the library you can ask those on the `#javaapi` channel on the [Pokemon GO Reverse Engineering Slack](https://pkre.slack.com/). You can [get your invite here](https://shielded-earth-81203.herokuapp.com/).
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
**Description:**
[Short description of the issue observed. If this ia feature request you can modify the template as required.]
[Short description of the issue observed. If this is a feature request you can modify the template as required.]

**Steps to reproduce:**

Expand All @@ -16,4 +16,4 @@
[Please use pastebin if it's too long]

**Version:**
[The version of the lib you used]
[The version of the lib you used]
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,29 @@ ___
# Build
- Clone the repo and cd into the folder
- `` git submodule update --init ``
- verify that you have gradle in your path
- `` gradle build bundle ``
- compile and package
- `` ./gradlew build bundle ``
- you should have the api bundled in ``build/libs/PokeGOAPI-Java_bundle-0.0.1-SNAPSHOT.jar``

PS : To eclipse user, you may build one time and add the generated java class for proto into eclipse path : Right click on the project > Build path > New Source Folder > Type 'build/generated/source/proto/main/java' > Finish
PS : To Eclipse user, you must build once : `` ./gradlew build `` and add the generated java class for proto into eclipse source path : Right click on the project > Build path > Configure Build Path > Source > Add Folder > Select `build/generated/source/proto/main/java` > Finish

# Usage
Include the API as jar from your own build, or use Maven/Gradle/SBT/Leiningen: https://jitpack.io/#Grover-c13/PokeGOAPI-Java/master-SNAPSHOT

Mostly everything is accessed through the PokemonGo class in the API package.

The constructor of PokemonGo class requires a AuthInfo object which can be obtained from GoogleLogin().login or PTCLogin().login, and a OkHttpClient object.
The constructor of PokemonGo class requires a AuthInfo object which can be obtained from GoogleLogin().login or PtcLogin().login, and a OkHttpClient object.

EG:
```java
OkHttpClient httpClient = new OkHttpClient();
AuthInfo auth = new GoogleLogin(httpClient).login("token");
PokemonGo go = new PokemonGo(auth,httpClient);
//Use Google
//First Ever Login. Persist info when you recieve callback
PokemonGo go = new PokemonGo(new GoogleCredentialProvider(httpClient,listner),httpClient);
//Subsequently
PokemonGo go = new PokemonGo(new GoogleCredentialProvider(httpClient,refreshToken),httpClient);
//Or use PTC
PokemonGo go = new PokemonGo(new PtcCredentialProvider(httpClient,username,password),httpClient);
Log.v(go.getPlayerProfile());
```
##Android Dev FAQ
Expand All @@ -57,13 +62,17 @@ You're running the sample code on the UI thread. Strict mode policy will throw a

This library is meant to be a Java implementation of the API. Google Volley is specific to Android and should not be introduced in this library. However, if you still want to refactor it, you should create it as a separate project.

- How can I use Android's native Google sign in with this library?

You can't. The Google Identity Platform uses the SHA1 fingerprint and package name to authenticate the caller of all sign in requests. This means that Niantic would need to add your app's SHA1 fingerprint and package name to their Google API Console. If you ever requested a Google Maps API key, you went through the same process. An alternative would be using a WebView to access the web based OAuth flow. This will work with the client ID and secret provided by this library.


## Contributing
- Fork it!
- Create your feature branch: `git checkout -b my-new-feature`
- Commit your changes: `git commit -am 'Usefull information about your new features'`
- Commit your changes: `git commit -am 'Useful information about your new features'`
- Push to the branch: `git push origin my-new-feature`
- Submit a pull request :D
- Submit a pull request on the `Development` branch :D

## Contributors
- Grover-c13
Expand Down
14 changes: 12 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ protobuf {
}
}

def checkstyleOutputDir = "${project.rootDir}/build/reports/checkstyle/"
def checkstyleOutputDir = "${project.projectDir}/build/reports/checkstyle/"

checkstyle {
toolVersion = '7.0'
configFile = file("${project.rootDir}/config/checkstyle.xml")
configFile = file("${project.projectDir}/config/checkstyle.xml")
configProperties = [ "suppressionFile" : file("${project.projectDir}/config/suppressions.xml")]
reportsDir = file(checkstyleOutputDir)

ignoreFailures = false
Expand Down Expand Up @@ -107,3 +108,12 @@ idea {
sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java");
}
}

task sourcesJar(type: Jar) {
from sourceSets.main.java.srcDirs
classifier = 'sources'
}

artifacts {
archives sourcesJar
}
23 changes: 5 additions & 18 deletions config/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<module name = "Checker">
<module name="SuppressionFilter">
<property name="file" value="config/suppressions.xml"/>
<property name="file" value="${suppressionFile}"/>
</module>

<property name="charset" value="UTF-8"/>
Expand Down Expand Up @@ -57,7 +57,6 @@
<property name="option" value="TEXT"/>
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
</module>
<module name="NeedBraces"/>
<module name="LeftCurly">
<property name="maxLineLength" value="120"/>
</module>
Expand All @@ -67,10 +66,10 @@
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyConstructors" value="false"/>
<property name="allowEmptyMethods" value="false"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<property name="allowEmptyLoops" value="false"/>
<message key="ws.notFollowed"
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded"
Expand Down Expand Up @@ -149,17 +148,8 @@
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="2"/>
</module>
<module name="AbbreviationAsWordInName">
<property name="ignoreFinal" value="false"/>
<property name="allowedAbbreviationLength" value="1"/>
</module>
<module name="OverloadMethodsDeclarationOrder"/>
<module name="VariableDeclarationUsageDistance"/>
<module name="CustomImportOrder">
<property name="specialImportsRegExp" value="com.google"/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
</module>
<module name="MethodParamPad"/>
<module name="OperatorWrap">
<property name="option" value="NL"/>
Expand All @@ -174,9 +164,6 @@
</module>
<module name="NonEmptyAtclauseDescription"/>
<module name="JavadocTagContinuationIndentation"/>
<module name="SummaryJavadocCheck">
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
</module>
<module name="JavadocParagraph"/>
<module name="AtclauseOrder">
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
Expand Down Expand Up @@ -204,4 +191,4 @@
</module>
<module name="CommentsIndentation"/>
</module>
</module>
</module>
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Jul 17 19:51:46 PDT 2016
#Sat Jul 23 04:51:41 PDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
30 changes: 25 additions & 5 deletions src/main/java/com/pokegoapi/api/PokemonGo.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.pokegoapi.api.inventory.Inventories;
import com.pokegoapi.api.map.Map;
import com.pokegoapi.api.player.PlayerProfile;
import com.pokegoapi.auth.CredentialProvider;
import com.pokegoapi.exceptions.LoginFailedException;
import com.pokegoapi.exceptions.RemoteServerException;
import com.pokegoapi.main.RequestHandler;
Expand Down Expand Up @@ -49,31 +50,50 @@ public class PokemonGo {
@Setter
private double altitude;

private CredentialProvider credentialProvider;

private RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo authInfo;

/**
* Instantiates a new Pokemon go.
*
* @param auth the auth
* @param client the client
*/
public PokemonGo(RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo auth, OkHttpClient client)
public PokemonGo(CredentialProvider credentialProvider, OkHttpClient client)
throws LoginFailedException, RemoteServerException {

if (credentialProvider == null) {
throw new LoginFailedException("Credential Provider is null");
} else {
this.credentialProvider = credentialProvider;
}

playerProfile = null;

// send profile request to get the ball rolling
requestHandler = new RequestHandler(this, auth, client);

requestHandler = new RequestHandler(this, client);
playerProfile = new PlayerProfile(this);
inventories = new Inventories(this);

playerProfile.updateProfile();
inventories.updateInventories();

// should have proper end point now.

map = new Map(this);
}

/**
* Fetches valid AuthInfo
*
* @return AuthInfo object
* @throws LoginFailedException when login fails
*/
public RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo getAuthInfo()
throws LoginFailedException, RemoteServerException {
return credentialProvider.getAuthInfo();
}


/**
* Gets player profile.
*
Expand Down
Loading