+ Start a Discussion
Roman RauerRoman Rauer 

Using API's without authentication

Hi there :)

i'm currently working on an native Android app for my company and ran into some problems with Salesforce lately.

I hope i can find some help here.

What i want to achieve:
The company has a lot of Accounts in Salesforce with 3 important fields for the app: Name, Business (Workshop or Parts Dealer) and location(latitude, longitude)
I would like to show those Accounts(Workshops/Parts Dealers) as markers on a google map in my Android app based on a radius around the user's current location. So it would be more than sufficient to get the data as JSON or XML(i read about sObjects, which would be nice too)

The app will be freely available on Google Play Store and every user should be able to see all the Workshops/Parts dealers around the world.

The problem i'm facing is that i can't find a way to fetch the data inside my app without authenticating every user with a Salesforce-Login. 
Which API is the best to use in this case?

It would be so awsome if anybody could help me with this problem.

What i tried so far: 
- SalesforceMobileSDK: If i extend SalesForceApplication i always end up with the Salesforce-Login Screen.
It seems that every client has to be authenticated for API-calls to work. I tried using the method "peekUnauthenticatedRestClient", but this method only works on full path URL's(e.g. "https://api.spotify.com/v1/search?q=James%20Brown&type=artist"), which isn't really practically for my Use-case.

- I feel like i read nearly all docs about salesforce api, but can't quite get my head around how to solve this problem, although it seems like to be a pretty common use-case.  

- would a salesforce-apex method which would select all records inside a set radius around the user's location be accessable without authentication?

Thanks for your help in advance!

Roman
Best Answer chosen by Roman Rauer
Santosh Bompally 8Santosh Bompally 8
Follow this -> 
1) Write a Restservice to expose your data. 
@RestResource(urlMapping='/Account')
global with sharing class MyRestResource {

 
    @HttpGet
    global static List<Account> doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
       List< Account>  result = [SELECT Id, Name, Business,Location FROM Account ];
        return result;
    }
  
}

2)  Create a Community and provide access to apex class and account object to the Guest user profile. 
    Samplecommunity url -> https://somedomain.cs16.force.com/communityname

3) Go to workbench and test your API using rest explorer 
    relative url ->  /services/apexrest/Account
4) Your public url will now be   https://somedomain.cs16.force.com/communityname/services/apexrest/Account 

Mark as Best Answer if it helps. 

Thanks, 
Santosh 

 

All Answers

Santosh Bompally 8Santosh Bompally 8
Follow this -> 
1) Write a Restservice to expose your data. 
@RestResource(urlMapping='/Account')
global with sharing class MyRestResource {

 
    @HttpGet
    global static List<Account> doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
       List< Account>  result = [SELECT Id, Name, Business,Location FROM Account ];
        return result;
    }
  
}

2)  Create a Community and provide access to apex class and account object to the Guest user profile. 
    Samplecommunity url -> https://somedomain.cs16.force.com/communityname

3) Go to workbench and test your API using rest explorer 
    relative url ->  /services/apexrest/Account
4) Your public url will now be   https://somedomain.cs16.force.com/communityname/services/apexrest/Account 

Mark as Best Answer if it helps. 

Thanks, 
Santosh 

 
This was selected as the best answer
Roman RauerRoman Rauer
Thank you! 

That was exactly what i needed!
Spotify GeekSpotify Geek
Geeks MatrixGeeks Matrix
Download Latest Spotify Premium Apk: https://geeksmatrix.com/spotify-premium-apk/
Martin RoxMartin Rox
Read our Latest Blog Post on Tellpizzahut Review: https://survifier.com/tellpizzahut-survey/
Jerry SahaJerry Saha
Thank you so much, Santosh Bompally for sharing such an in-depth answer honestly it helped me a lot. You can also visit my blog https://smartwatchzone.in
afza ahmadafza ahmad
very usefull info thank you so much for sharing if you are interested in horse riding Here for Horse Riding (https://www.studiomotions.co.uk)or in asian wedding photography  Here for photography (https://www.studiomotions.co.uk)
please Visit us 
afza ahmadafza ahmad
Good and Thanks for sharing this valuable information with us love from  (https://mriceland.is/)
Eoin MrganEoin Mrgan
Download Viva Video Pro Apk 2019 - https://vivavideopro.co/
Devian Studio 2Devian Studio 2
Download Free ringtones for mobile phone - https://ring320kbps.com/
apk windapk wind
Download Spotify Mod Apk: https://apkwind.com/spotify-premium-apk/
Alex JhonAlex Jhon
Thanks for sharing this cool stuff, Visit our site Gotechswag (https://gotechswag.com/) these types of amazing stuff like Spotify premium Apk (https://gotechswag.com/spotify-premium-apk/)
juli sinhajuli sinha
Download Saavn pro Apk (https://trickspanel.com/saavn-pro-mod-apk-download/) for free and enjooy the latest updated songs for free.
Hungry SharkHungry Shark
Download Hungry Shark World Mod Apk https://hungrysharkworldmodapk.com/
juli sinhajuli sinha
Download the latest Pandora One (https://trickspanel.com/pandora-one-cracked-mod-apk-download/) for lifetime enjoy music and own radio stations.
Revan SatavRevan Satav
The experience of a Spotify Music app is little more clunky on mobile.
With the Spotify app and a free account you can pick 15 playlists featuring up to 750 songs in total.

But If you want to pick unlimites playlist and all premium features for free of cost.

Then you can visit our Spotify Premium APK (https://spotifylover.com/spotify-premium-apk/) website. 
Where we are published trick to get spotify premium account for free.
 
Rajesh Jha 4Rajesh Jha 4
Spotify Premium Apk (https://Spotifypremiumapk.me)
Tune GuruTune Guru
Latest Bollywood Movie Ringtone Free Download (https://tuneguru.in/latest-bollywood-movie-ringtone/)
Mark AbbasisMark Abbasis
Wonderful information shared on Sales force. If you love listening to songs online, you may download Spotify Premium Apk from our website Spotify Mod Apk (https://www.techiematch.com/spotify-premium-apk/)
Pavan Mishra 5Pavan Mishra 5
Nice! Thank you so much for sharing this information with us. You must also check out YoWhatsApp Apk (https://thefunexplode.com/yowhatsapp-download-apk/
seen parkerseen parker
Complte Guide about spotify premium apk (https://spotifypremiumapklatest.com/) and Latest Download with all version IOS , Anroid , and PC.
Akhand Pratap SinghAkhand Pratap Singh
Manage your task with these https://www.geekyarea.com/best-to-do-list-app/ (https://www.geekyarea.com/best-to-do-list-app/)
juli sinhajuli sinha
Play and keep updated with the updated forest games (https://trickspanel.com/best-the-forest-mods/) and enjoy the jungle life.
Apk LegitApk Legit
Download Spotify Premium Apk (https://apklegit.com/spotify-premium-apk) to enjoy the latest updated songs for free
Carl johnson 13Carl johnson 13
Get 2019 latest GTA vice city cheats pc (https://www.gtacheatcode.com/2019/12/gta-vice-city-cheats.html" target="_blank) and enjoy your grand theft auto game.
rosie white 4rosie white 4
Hey admin love to read your article and get so much data from your blog and learn new things. You write in a good way, and i am amazed with your blogging, you will definitely achieve success. Please give some more information about Anganwadi Jobs (https://www.totaljobshub.in/anganwadi-recruitment-2017/)
Revan Satav 3Revan Satav 3
This is website which provides paid spotify account for free.
The experience is a little more clunky on mobile for Spotify Premium Apk (https://spotifylover.com/spotify-premium-apk/).
With the Spotify app and a free account you can pick 15 playlists featuring up to 750 songs in total.

But If you want to pick unlimited playlist and all premium features for free of cost.

Then you can visit our Spotify Premium APK website. 
Where we are published trick to get spotify premium account for free.
 
Emi SantosEmi Santos
That's great and I was also trying to use the API on https://mp3jaw.site/ which is MP3 search engine service for free...
The HypeThe Hype
Great We Recently Shared Fm whatsapp (https://flosshype.com/fmwhatsapp/) & pubg names (https://flosshype.com/pubg-names/) on our site please checkout
Carl johnson 18Carl johnson 18
Grab these amazing and Latest 2020 GTA 3 CHEATS (https://www.gtacheatcode.com/2019/11/gta-3-cheats-code.html) PC.
Revan Satav 3Revan Satav 3
Do you like to listen music online ? Spotify Premium APK (https://mobilescraper.com/spotify-premium-apk/) is best mobile / desktop application to stream songs online.
ooheman dasooheman das
Grab these amazing and Latestjio music (https://www.apkhunt.in/jio-saavn-pro-apk-download-latest/)
ooheman dasooheman das
Afza Ahmad 9Afza Ahmad 9
thank you for sharing this Information With Us if Anyone needs service About  PAYG Calculator (https://www.paycalculators.com.au/
 
dost mazaridost mazari
if you are song lovers then you must visit 
Spotify Premium Apk (https://gamesroute.com/spotify-premium-apk/)
Sam UilbertonSam Uilberton
Thanks for this useful information.
Our translation service : http://ideyatercume.az
Sam UilbertonSam Uilberton
Check for you seo xidməti (http://seolab.az) with us
Sam UilbertonSam Uilberton
We are cargo company  (http://vipex.az) . It make our work so easy.
APKPure DLAPKPure DL
Ryan Carter 13Ryan Carter 13
kaushal sharma 24kaushal sharma 24
check the best idea Ihttps://realtimenews.org.in/)
kaushal sharma 24kaushal sharma 24
check the best (https://realtimenews.org.in/)
shane carruthshane carruth
This particular blog is without a doubt awesome and also amusing. I have found a lot of interesting stuff out of it. I ad love to visit it again soon. Thanks! Dqfansurvey (http://dqfansurveyguide.com/)
Sam Billing 5Sam Billing 5
Well. That's a great idea to see here. Spotify APK Premium (https://thetrickyhunt.com/spotify-premium-apk/) is for sure one of the finest platforms that have opened up the ways to seamless streaming. Just enjoy your favourite tracks and podcasts channels as per your convenience. If you are willing to explore the world of Spotify more, here - Tricky hunt (https://thetrickyhunt.com)
Sam Billing 5Sam Billing 5
It's a great article. Thanks for this. Have you checked out? Whatsapp dare games (https://www.tricksclub.com/whatsapp-dare-games-messages/)? Not Yet ? Don't worry just click on the given link & get 1000+ Latest Whatsapp dare games
Andrew John 8Andrew John 8
Download whatsapp plus apk latest version (Whatsapp Plus Apk (https://apkcunk.com/whatsapp-plus-apk/)) for more apk updates visit - apkcunk.com
Lee mark 1Lee mark 1

great dude!!! you can download the fujitsu driver in our site:

Fujitsu Scansnap (https://www.fujitsuscansnap.net/), Fujitsu Scansnap Driver (https://www.fujitsuscansnapdriver.com/), Smadav 2021 (https://www.smadav-2021.com/), Smadav 2021 (https://www.smadav2021.net/)