Commit Graph

67 Commits

Author SHA1 Message Date
Lewin Bormann
51e0b9d163 docs(installed): Mention the InstalledFlow in the documentation 2016-09-04 19:29:56 +02:00
Lewin Bormann
cb66737988 fix(test): Add missing import to authenticator tests 2016-09-04 19:20:59 +02:00
Lewin Bormann
a4532f27b4 fix(helper): Parse app secrets into right type 2016-08-31 20:46:10 +02:00
Lewin Bormann
c4231e9499 feat(helpers): Add helpers for reading/parsing JSON
This is boilerplate that can easily be provided to users of the library.
2016-08-31 20:07:33 +02:00
Lewin Bormann
85b12dd3e8 refactor(common): Rename common -> types 2016-08-31 20:01:24 +02:00
Lewin Bormann
9e59bf0496 refactor(all): More flows demand for a different structure
I mainly resolved some circular dependencies that had crept in, and
moved code around. I renamed helper.rs because that was not really an
appropriate name anymore, and moved the delegate code into a new module.
2016-08-31 19:48:38 +02:00
Sebastian Thiel
7a907eb318 fix(dependencies): use latest version of serde_codegen
In the way it's meant to be used, which means it uses it's
own version of syntex, to assure it doesn't clash anymore in
unforseen ways.
2016-07-17 11:36:21 +02:00
Sebastian Thiel
57a3151d4d fix(flows): save Token properly
The installed flow didn't explicitly set the retrieved token
absolute, which would cause failures down the road.
2016-05-20 18:24:28 +02:00
Sebastian Thiel
31bad1ae53 chore(features): rename with_syntex to with-syntex
This makes the name similar to the one used in quasi, aster, serde
and the likes.
2016-05-20 14:57:09 +02:00
Sebastian Thiel
a3bc7e88b5 chore(serde): upgrade to latest version for stable
Now it builds with stable too, it appears.
2016-05-20 12:15:23 +02:00
Sebastian Thiel
22bb255a55 fix(dependencies): work with latest dependencies on nightly
Stable doesn't quite work yet due to the cargo issue further
described [here][cargo-issue]

[cargo-issue]: https://github.com/rust-lang/cargo/issues/2064
2016-05-20 08:57:06 +02:00
Sebastian Thiel
815d8863ed Merge branch 'disk-token-storage' of https://github.com/dermesser/yup-oauth2 into all-upgrades 2016-05-20 07:58:14 +02:00
Lewin Bormann
a7e8423fe0 refactor(installedflow): Apply suggestions from PR 2016-04-27 19:25:40 +02:00
Lewin Bormann
ae5e94bf7b fix(DiskTokenStorage): make DiskTokenStorage::new() return a Result<> 2016-04-25 19:14:53 +02:00
Lewin Bormann
b039dc0cdc refactor(installedflow): use app secret instead of single params 2016-04-16 21:02:57 +02:00
Lewin Bormann
9b31070edb fix(installed): Genericize token/auth URI
This means that in theory other providers besides Google could be used.
2016-04-16 20:54:11 +02:00
Lewin Bormann
77355888f2 feat(flows): Implement flow for installed apps
The "Installed App Flow" requires user interaction; we first generate a
URL that the user has to navigate to. Then, the user either pastes a
displayed code into the app being authorized, or the OAuth provider
redirects the user's browser to a webserver that is running on
localhost. This webserver is provided by the library and the flow should
work automatically. Extensive documentation can be found here:
https://developers.google.com/identity/protocols/OAuth2InstalledApp
An example for the InstalledFlow with the Drive API is here:
https://gist.github.com/dermesser/8c915ec4c88ee8e8927e7d40b276ca52
2016-04-16 14:45:45 +00:00
Lewin Bormann
2cb5250e72 feat(storage): Implement DiskTokenStorage
DiskTokenStorage is a TokenStorage that stores its tokens in a JSON file
on disk. That file can be read in later, and the tokens in it reused.
(The idea for a cache file is from here:
https://developers.google.com/drive/v3/web/quickstart/go)
2016-04-15 19:42:50 +00:00
Sebastian Thiel
c18ae07bbb imp(duration): use std::time::Duration everywhere
This gets rid of the time crate, which was necessary only while Duration wasn't stable
in std.
2016-02-07 10:09:36 +01:00
Sebastian Thiel
c039db56cd fix(secret): allow project_id field
It seems to be part of the google secrets now ... lets see if this improves anything
2016-02-07 09:37:34 +01:00
Sebastian Thiel
850ddbf5ba fix(rustup): add now mandatory lifetimes
fixes #13
2015-12-23 18:34:29 +01:00
Sebastian Thiel
ad0bde3092 fix(tests): assure tests actually work
Previously we simply forgot to run the tests, and published test-code
that didn't really work.
2015-08-08 11:45:53 +02:00
Sebastian Thiel
a169d9610d chore(serde): update to serde 0.5.0
Serde move all json code into a separate crate, which we are now pulling
in separately.
2015-08-08 10:40:14 +02:00
Sebastian Thiel
624ec51e8f chore(build.rs): moved into src/ dir 2015-06-24 16:34:53 +02:00
Sebastian Thiel
6a5915d7d6 fix(lib): remove macro usage to work on stable
As usage of the `!include` macro is enforced, there is currently no way
to use the exported macros from `yup_hyper_mock`. Now some more
boilerplate code was added to make it work anyway.
2015-06-18 17:58:22 +02:00
Sebastian Thiel
f59d97d4c5 refactor(lib): remove empty macros
Even though these made `cargo build` work, I think what's really needed
in the long run is to make it work for `cargo test` as well.
2015-06-11 11:49:38 +02:00
Sebastian Thiel
a260b13868 fix(lib): setup nightly crate meta data correctly
* Previously the meta-data was applied to the crate, which doesn't seem
  to work.
* attempted to make `examples/auth.rs` work on stable. This isn't
  properly tested now, as tests don't compile.

We are now at a state were stable as well as nightly work similarly,
but fail because `include!` doesn't behave correctly if macros are
involved. Namely it happens before crates are linked, yet it will
try to expand macros right away, which is a problem.

If the macro is defined in an empty fashion, it will actually be used
at include time, and expanded. Which causes issues further down the
compilation.

With the current 'fix' we manage to at least make everything but
`cargo test` work.

Related to #12
2015-06-11 11:29:10 +02:00
Sebastian Thiel
37231fad2e chore(make): added makefile
* It should help to keep track of how to properly call cargo in nightly
  mode. After all, I have wasted some time, multiple times just trying
  to figure out that I forgot to add the nightly feature.
* Slightly improved structure of lib.rs and includes

Related to #12
2015-06-11 10:57:57 +02:00
Sebastian Thiel
0901497d89 fix(syntex): cleanup, build works on stable
It seems it doesn't like one line in particular (helper.rs:450),
which causes syntex to crash. Commenting it out does the trick.
2015-05-26 17:46:47 +02:00
Sebastian Thiel
9b2f9e77be feat(syntex): basic infrastructure
It doesn't yet work on nightly due to a panic in
https://goo.gl/RyM4GT

Might have something to do with me being on nightly,
and some cargo-related hickoup.
2015-05-26 14:41:31 +02:00
Sebastian Thiel
598f5ed496 chore(cargo):update to latest hyper/yup-hyper-mock
This fixes the macro issues that caused us so much trouble
2015-05-18 10:46:38 +02:00
William Orr
47b68cf401 fix(rustup): workaround rustlang bug
Due to https://github.com/rust-lang/rust/issues/22252, r-value
temporaries outlive the lifetimes of variables bound with let
statements in a function body. Because of this, device.rs fails to
compile against newer rustc nightlies.

This implements a simple workaround that binds the result of the match
in `request_code` to a local variable before returning it. This allows
it to have the same lifetime as `req` in one of the previous let
bindings.
2015-05-10 18:15:21 -07:00
Sebastian Thiel
7383f5efb6 fix(hyper): update to hyper v0.4.0
* `hyper::HttpError` is now the more versatile `hyper::Error`
2015-05-08 11:39:45 +02:00
Sebastian Thiel
9cafc3720e refactor(url): simplify form_urlencode call
It's a great simplification and also uses less (if not zero) overhead,
finally.
Requires url v0.2.33
2015-05-05 08:57:13 +02:00
Sebastian Thiel
a395fe892c fix(JsonError): make error field non-optional
* to makes using the structure much easier.
* incremented version

Fixes #6
2015-05-02 09:06:57 +02:00
Sebastian Thiel
b08b239e88 fix(json): assure we understand json errors
We would actually fail to decode an error, and then assume it's a valid
result, unwrapping another failed attempt to decode the json string
returned by the server.

Cause seems to be that the json error structure now conains an
additional field, 'error_uri'.

* we removed a debug printing ... .
* incremented version
2015-05-01 19:39:57 +02:00
Sebastian Thiel
f95bb816f7 fix(TokenStorage): set() returns Result<(), _>
That we, we are conforming to the style postulated by the standard
library, which, if in doubt, should always be preferred.

Fixes #5
2015-04-30 17:08:31 +02:00
Sebastian Thiel
e05e5553e3 feat(serde): use serde instead of rustc_serialize
That way, we can pretty-print the respective application secret
strucures. This is primiarily of interest for the main client of this
library, namely Google APIs RS.

Version incremented.

Fixes #2
2015-04-30 14:18:44 +02:00
Sebastian Thiel
3ca51ccfe2 fix(rustup): 1.1.0-nightly (97d4e76c2 2015-04-27)
Also incremented version
2015-04-29 09:53:27 +02:00
Sebastian Thiel
727c1d801b fix(rustup): replace sleep with sleep_ms
Now it works with the latest compiler. I wonder why I didn't notice
that before ... .
2015-04-26 21:13:45 +02:00
Sebastian Thiel
2a1247bae0 fix(common): remove obsolete marker trait
... and version-up right away :).
2015-04-26 20:50:27 +02:00
Sebastian Thiel
690bcdb627 fix(helper): unset stored token on refresh failure
Previously we would have no way of getting rid of invalid/revoked
tokens, which would render the application unusable unless the user
would delete the token manually.

Related to https://github.com/Byron/google-apis-rs/issues/79
2015-04-24 09:30:52 +02:00
Sebastian Thiel
1ce4147d54 fix(refresh): use correct URL for refresh flow
This also allowed us to simplify the API once again.
2015-04-23 17:24:20 +02:00
Sebastian Thiel
2481c75c31 fix(API): review Result types and adapt code
* Do not return massive custom result enums, but instead adhere to the
  `Result` convention. This natively fixed our problem related to having
  to make unnecessary clones, making our design much cleaner.

Fixes #4
2015-04-23 17:01:21 +02:00
Sebastian Thiel
2cdf8bbf76 fix(API): overall improved error handling
* Return `Result<Token, Box<Error>>` type wherever feasible
* increment version to 0.3.5
* remove all usages of depreceated std items
2015-04-23 13:47:49 +02:00
Sebastian Thiel
84454d1736 fix(rustup): (abf0548b5 2015-04-15) (built 2015-04-15) 2015-04-17 06:39:16 +02:00
Sebastian Thiel
0222a19e9d fix(version-up): v0.3.3
* hyper adjustments to deal with Client without type parameter
* adjust to changed crate name conventions, '-' are converted to '_'

Fixes #3
2015-04-08 16:40:48 +02:00
Sebastian Thiel
2489b81383 fix(update-dependencies): rustup + dep-up
* updated to rustc (be9bd7c93 2015-04-05)
* use latest hyper

The latter required us to deal with HttpError not being clonable
anymore.
2015-04-07 10:35:25 +02:00
Sebastian Thiel
feba2d0e5a feat(header): Authorization Scheme for Oauth
Allows not natively use Oauth2 schemes with hyper Authorization headers.
Added support for serialization and parsing.
2015-03-22 11:55:05 +01:00
Sebastian Thiel
0710d310f8 feat(api_key): GetToken.api_key()
Allows to get API keys in case there is no known scope.
There might be alterations to this, as I am unsure how it's supposed
to be implemented.
2015-03-16 13:41:19 +01:00