We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, I'm following the Android tutorial
After having followed the Backend tutorial and having confirmed that it worked perfectly fine when hit from a browser
The issue I'm facing is that when it's time to do the exchange code to access token, my local server is returning unauthorized redirect_uri as follows
I really appreciate your help and would like you to assist me with this, I'll share my code/config/etc below:
<resources> <string name="app_name">Tesla Login</string> <string name="smartcar_auth_scheme">scab94b2dd-5adf-421a-ae89-0b4099563ada</string> <string name="client_id">ab94b2dd-5adf-421a-ae89-0b4099563ada</string> <string name="smartcar_auth_host">exchange</string> <string name="app_server">http://10.0.2.2:8000</string> </resources>
class MainActivity : ComponentActivity() { private lateinit var CLIENT_ID: String private lateinit var REDIRECT_URI: String private lateinit var SCOPE: Array<String> private lateinit var smartcarAuth: SmartcarAuth override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val connectButton = findViewById<Button>(R.id.connect_button) CLIENT_ID = getString(R.string.client_id) REDIRECT_URI = getString(R.string.smartcar_auth_scheme) + "://" + getString(R.string.smartcar_auth_host) SCOPE = arrayOf("required:read_vehicle_info") smartcarAuth = SmartcarAuth( CLIENT_ID, REDIRECT_URI, SCOPE, true ) { handleResponse(it) } smartcarAuth.addClickHandler(this, connectButton) } fun handleResponse(smartcarResponse: SmartcarResponse) { val client = OkHttpClient() Thread { try { val exchangeRequest: Request = Request.Builder() .url(getString(R.string.app_server) + "/exchange?code=" + smartcarResponse.code) .build() val exchangeResponse = client.newCall(exchangeRequest).execute() if (!exchangeResponse.isSuccessful) { throw IOException("Unexpected code $exchangeResponse") } val exchangeJsonBody = exchangeResponse.body!!.string() val exchangeJObject = JSONObject(exchangeJsonBody) val accessToken = exchangeJObject.getString("access_token") val infoRequest: Request = Request.Builder() .url(getString(R.string.app_server) + "/vehicle") .addHeader("Authorization", "Bearer $accessToken") .build() val infoResponse = client.newCall(infoRequest).execute() if (!infoResponse.isSuccessful) { throw IOException("Unexpected code $infoResponse") } val infoJsonBody = infoResponse.body!!.string() val infoJObject = JSONObject(infoJsonBody) val make = infoJObject.getString("make") val model = infoJObject.getString("model") val year = infoJObject.getString("year") Log.d("SMARTCARRESPONSE", "handleResponse: $make $model and $year") } catch (e: IOException) { e.printStackTrace() } catch (e: JSONException) { e.printStackTrace() } }.start() } }
<activity android:name="com.smartcar.sdk.SmartcarCodeReceiver" android:exported="true"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="@string/smartcar_auth_host" android:scheme="@string/smartcar_auth_scheme" /> </intent-filter> </activity>
'use strict'; const express = require('express'); const exphbs = require('express-handlebars'); const smartcar = require('smartcar'); const app = express(); app.engine( '.hbs', exphbs({ defaultLayout: 'main', extname: '.hbs', }), ); const client = new smartcar.AuthClient({ mode: 'test', }); app.set('view engine', '.hbs'); const port = 8000; // TODO: Authorization Step 1: Initialize the Smartcar object // global variable to save our accessToken let access; app.get('/login', function(req, res) { const scope = ['read_vehicle_info']; const authUrl = client.getAuthUrl(scope); res.render('home', { url: authUrl, }); }); app.get('/exchange', async function(req, res) { const code = req.query.code; console.log(code); access = await client.exchangeCode(code); res.redirect('/vehicle'); }); app.get('/vehicle', async function(req, res) { const { vehicles } = await smartcar.getVehicles(access.accessToken); const vehicle = new smartcar.Vehicle(vehicles[0], access.accessToken); const attributes = await vehicle.attributes(); res.render('vehicle', { info: attributes, }); }); app.listen(port, () => console.log(`Listening on port ${port}`));
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi, I'm following the Android tutorial
After having followed the Backend tutorial and having confirmed that it worked perfectly fine when hit from a browser
The issue I'm facing is that when it's time to do the exchange code to access token, my local server is returning unauthorized redirect_uri as follows
I really appreciate your help and would like you to assist me with this, I'll share my code/config/etc below:
Strings.xml
MainActivity
Android Manifest
Node server index.js
SmartCar Dashboard
Env Variables exported as well
The text was updated successfully, but these errors were encountered: