Skip to content

Hide api key #1

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 27
compileSdkVersion 28

lintOptions {
disable 'InvalidPackage'
Expand All @@ -25,7 +25,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.moviesstreams"
minSdkVersion 16
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.2.1'
}
}

Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
8 changes: 5 additions & 3 deletions lib/api/tmdb_api.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@


import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:movies_streams/api/tmdb_api_key.dart';
import 'package:movies_streams/models/movie_genres_list.dart';
import 'package:movies_streams/models/movie_page_result.dart';

Expand All @@ -12,7 +15,6 @@ import 'package:movies_streams/models/movie_page_result.dart';
///

class TmdbApi {
static const String TMDB_API_KEY = "PUT YOUR KEY, HERE";
static const String baseUrl = 'api.themoviedb.org';
final String imageBaseUrl = 'http://image.tmdb.org/t/p/w185/';
final _httpClient = new HttpClient();
Expand All @@ -29,7 +31,7 @@ class TmdbApi {
baseUrl,
'3/discover/$type',
<String, String>{
'api_key': TMDB_API_KEY,
'api_key': tmdbApiKey,
'language': 'en-US',
'sort_by': 'popularity.desc',
'include_adult': 'false',
Expand Down Expand Up @@ -58,7 +60,7 @@ class TmdbApi {
baseUrl,
'3/genre/$type/list',
<String, String>{
'api_key': TMDB_API_KEY,
'api_key': tmdbApiKey,
'language': 'en-US',
},
);
Expand Down
13 changes: 13 additions & 0 deletions lib/api/tmdb_api_key.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// If you a hosting a fork of the app repository on any public server
// you are advised to remove this file from the repository before
// adding the secret api key.
// to do this run:
// git rm --cached lib/api/tmdb_api_key.dart
// git commit -m 'removed secret api key from repository' -o lib/api/tmdb_api_key.dart

const String tmdbApiKey = 'put your api key here';

// the api read access token is not required for this app to run.
// I am including it anyway because it is delivered together with the key
// and might be of use later on.
const String tmdbApiReadAccessToken ='put the api read acces token here';