Trying on the "Integrating with OAuth Excercise"

The item "e" at page 21 have the follow instruction to add to URL:
"https://accounts.google.com/o/oauth2/auth?client_id=" + Site.ClientId + "&redirect_uri=" + MakeAbsoluteURL("/Employees_OAuth/GoogleCallback.aspx") + "&scope=" + EncodeUrl(Site.Scopes) + "&response_type=code&access_type=offline&approval_prompt=force"
But It returns error attached, so, how to do it in the right way? Maybe my Studio have some missing module, as I´ve just got it and start studing.
Any idea where´s my mistake?
Txs...

Walter Franco

Hi Walter,

By copy/pasting directly from the exercise pdf, some characters (like double quotes) and functions may not be recognized in the expression editor by Service Studio.

Try typing the expression from the exercise yourself and make sure you have the used functions available as dependencies in your module.

MakeAbsoluteURL() function comes from HTTPRequestHandler module and EncodeURL() is already a built-in function you have available in your module. Site.Scopes is a site property you have to create yourself at the bottom of the Data Tab.

Hope this helps.

Regards,

Nordin

Hi Walter,

I agree with Nordin, exercise PDFs with syntax highlighting seem to add invisible "color characters" that are copy&pasted along with the text and are not recognized by Service Studio.

Consider using the text you have on your topic itself, as that one should be stripped out of any weird invisible characters:

"https://accounts.google.com/o/oauth2/auth?client_id=" + Site.ClientId + "&redirect_uri=" + MakeAbsoluteURL("/Employees_OAuth/GoogleCallback.aspx") + "&scope=" + EncodeUrl(Site.Scopes) + "&response_type=code&access_type=offline&approval_prompt=force"

Hope this helps!


Hi all,

I´ve made exactly this way, paying attention to weird characters, even made a paste to Notepad++ first to analyse the sintax of all the string.
Now I added the HTTPRequestHandler (txs Nordin), but even so, it´s still returning error on the sintax of External URL.
I can´t understand where´s my mistake.
Any ideas??
Txs

Walter Franco

Solution

Hi Walter,

I opened the exercise myself and tried copy/pasting the ExternalURL value from the PDF and it gave me the same syntax error. As you can see some of these weird red ~ lines appear like in the below examples (most times due to extra spaces).


So I focussed the cursor after those lines and pressed Backspace in order to delete them. And voila this is the result.

As you can see, now all the functions are recognized by Service Studio as they turned blue.

Just in case I copied the value I used and I will leave it here for you to try and paste it in the ExternalURL Value.

SyntaxEditor Code Snippet

"https://accounts.google.com/o/oauth2/auth?client_id=" + Site.ClientId + "&redirect_uri=" + MakeAbsoluteURL("/Employees_OAuth/GoogleCallback.aspx") + "&scope=" + EncodeUrl(Site.Scopes) + "&response_type=code&access_type=offline&approval_prompt=force"

You know what to do if you get those weird red lines again :).

Regards,

Nordin

EDIT: I tried pasting the value from the SyntaxEditor Code Snippet in the ExternalURL Value and it worked like a charm :)

Solution

Hi Nordin,

Thank you for your patience with me... I´m knew here and my 30 years developing is nothing when you have a new language to learn.... So... You can´t believe, but I´ve made exactly what you have done, and it doesn´t work...
So, I copy/paste your code and... as you said... Voila!!!! (lol)
It works!!!
Now...
I´ve other error at Google login... :-//
See attach, what is missing about OAuth??
Txs so much!!

Walter Franco

Hi Walter,

As your initial issue is solved now, please click 'Mark Post as Solution' for the post that helped you most in order to help other community members who might come across this thread to find the solution faster.

After that please create a new post for Google login error and I will try to get back to you on that later on.

Thanks!

Regards,

Nordin

Hi Nordin,

You´re right again...
Let´s do a new item for a new problem.
Thank you so much for your attention.
Regards...

Walter Franco
Poços de Caldas - MG
Brazil