Skip to content
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

The google-Api is not accessible without authorization any more... #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
public class UrlShortenerSteps extends ScenarioSteps {

RestTemplate restTemplate;
// The google-Api is only useable with an access-key as described here: https://developers.google.com/url-shortener/v1/getting_started#APIKey
// You need to activate the api at https://console.developers.google.com/project/{yourProjectNameHere}/apiui/apis/library and then get the api-key
// from https://console.developers.google.com/project/{yourProjectNameHere}/apiui/credential
String googleAccessKey = "somethingLikeAIzaSyBm8RAN4jzBiVQ0NOC91vYat7smWVW2azQ";

public UrlShortenerSteps() {
restTemplate = new RestTemplate();
Expand All @@ -28,7 +32,7 @@ public String shorten(String providedUrl) {

@Step("Expand Url for shortUrl={0}")
public String expand(String providedUrl) {
return restTemplate.getForObject("https://www.googleapis.com/urlshortener/v1/url?shortUrl={shortUrl}", String.class, providedUrl);
return restTemplate.getForObject("https://www.googleapis.com/urlshortener/v1/url?shortUrl={shortUrl}?key=" + googleAccessKey, String.class, providedUrl);
}

@Step
Expand Down